Warning message: Setting row names on a tibble is deprecated

Hi Community I have the following error
Can anyone can help me please
the code is as follows thanks in advance

rownames(pheno)<-geno0$Markername[-c(1,2)]
x<-data.frame(t(geno0[1:2,-c(1:6)]))
map<-data.frame(marker=rownames(x),chr=as.numeric(x[,1]),pos=as.numeric(x[,2]))
rownames(map)<-map$marker
geno<-geno0[-c(1:2),-c(1:6)]
rownames(geno)<-rownames(pheno)
Warning message:
Setting row names on a tibble is deprecated.

That is not an error, just a warning message letting you know that using row names with tibble class objects is deprecated because it is considered a bad practice.

It is not an error. R is telling you that tibbles, probably, fairly soon, will not accept rownames. I think it is a polite warning that code assigning row names in a tibble may not work next year.

The interesting thing is that the code you supply does not seem to have anything to do with tibbles. Perhaps you are using a tibble in earlier code?

hi thanks for your reply. I am having the error in my analysis (code attached) and i think the error is due to this warning. if this warning dont have anything to do can you please help me regarding the error please


> geno0<-bp[-c(3,4),]
> pheno<-geno0[-c(1,2),1:5]
> pheno[pheno=='-']<-NA
> pheno<-data.frame(apply(pheno,2,as.numeric))
> rownames(pheno)<-geno0$Markername[-c(1,2)]
> x<-data.frame(t(geno0[1:2,-c(1:6)]))
> map<-data.frame(marker=rownames(x),chr=as.numeric(x[,1]),pos=as.numeric(x[,2]))
> rownames(map)<-map$marker
> geno<-geno0[-c(1:2),-c(1:6)]
> rownames(geno)<-rownames(pheno)
Warning message:
Setting row names on a tibble is deprecated. 
> geno[geno=='-']<-NA
> View(genoR)
> seg<-t(apply(geno,2,function(x){
+   w<-c(0,0,0)
+   names(w)<-c('A','B','H')
+   y<-table(x)
+   w[names(y)]<-y
+   return(w)
+ }))
> f<-which(seg[,3]>10)
> geno<-geno[,-f]
> map<-map[-f,]
> geno[geno=='H']<-NA
> mm<-apply(geno,2,function(x){
+   length(which(is.na(x)))/length(x)
+ })
> f<-which(mm>.2)
> geno<-geno[,-f]
> map<-map[-f,]
> seg<-t(apply(geno,2,function(x){
+   w<-c(0,0)
+   names(w)<-c('A','B')
+   y<-table(x)
+   w[names(y)]<-y
+   return(w)
+ }))
> ra<-seg[,1]/seg[,2]
Error in seg[, 1] : subscript out of bounds
>

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

1 Like

Hi Andresrcs,
Thanks again for you reply the objective of my analysis is to analyse a qtl analysis of biparental population in R.
my code and packages are as follows library(ABHgenotypeR)
library(onemap)
library(ggplot2)
library(qtl)
setwd('Documents/inifap/proyectos/csic/double_haploid_map/')

reading file as I received it

geno0<-read.csv('0_rawdata/RQTL_BO21_MT.csv')

parental lines are duplicated

geno0<-bp[-c(3,4),]

separating geno, pheno, and map

pheno<-geno0[-c(1,2),1:5]
pheno[pheno=='-']<-NA
pheno<-data.frame(apply(pheno,2,as.numeric))
rownames(pheno)<-geno0$Markername[-c(1,2)]

x<-data.frame(t(geno0[1:2,-c(1:6)]))
map<-data.frame(marker=rownames(x),chr=as.numeric(x[,1]),pos=as.numeric(x[,2]))
rownames(map)<-map$marker

geno<-geno0[-c(1:2),-c(1:6)]
rownames(geno)<-rownames(pheno)
geno[geno=='-']<-NA

just checking segregation distortion

seg<-t(apply(geno,2,function(x){
w<-c(0,0,0)
names(w)<-c('A','B','H')
y<-table(x)
w[names(y)]<-y
return(w)
}))

f<-which(seg[,3]>10)
geno<-geno[,-f]
map<-map[-f,]

geno[geno=='H']<-NA

missing data

mm<-apply(geno,2,function(x){
length(which(is.na(x)))/length(x)
})

f<-which(mm>.2)
geno<-geno[,-f]
map<-map[-f,]

seg<-t(apply(geno,2,function(x){
w<-c(0,0)
names(w)<-c('A','B')
y<-table(x)
w[names(y)]<-y
return(w)
}))

ra<-seg[,1]/seg[,2]
f<-which(ra>4)
geno<-geno[,-f]
map<-map[-f,]
reprex.pdf (17.1 KB)

This is not reproducible because we don't have access to your local files and reading data from a pdf is not a trivial task, please read the guide on the link I gave you and try to provide a proper reproducible example.

Hello you can access the file by the following google docx link, apologise

Dear community,
i have the following code and error as follow

library(ABHgenotypeR)
library(onemap)
library(ggplot2)
library(qtl)
geno0<-bp[-c(3,4),]
View(bp)
View(geno0)
pheno<-geno0[-c(1,2),1:5]
pheno[pheno=='-']<-NA
pheno<-data.frame(apply(pheno,2,as.numeric))
rownames(pheno)<-geno0$Markername[-c(1,2)]
x<-data.frame(t(geno0[1:2,-c(1:6)]))
map<-data.frame(marker=rownames(x),chr=as.numeric(x[,1]),pos=as.numeric(x[,2]))
rownames(map)<-map$marker
geno<-geno0[-c(1:2),-c(1:6)]
rownames(geno)<-rownames(pheno)
Warning message:
Setting row names on a tibble is deprecated.
geno[geno=='-']<-NA
seg<-t(apply(geno,2,function(x){

  • w<-c(0,0,0)
  • names(w)<-c('A','B','H')
  • y<-table(x)
  • w[names(y)]<-y
  • return(w)
  • }))

f<-which(seg[,3]>10)
geno<-geno[,-f]
map<-map[-f,]
geno[geno=='H']<-NA
mm<-apply(geno,2,function(x){

  • length(which(is.na(x)))/length(x)
  • })

f<-which(mm>.2)
geno<-geno[,-f]
map<-map[-f,]
seg<-t(apply(geno,2,function(x){

  • w<-c(0,0)
  • names(w)<-c('A','B')
  • y<-table(x)
  • w[names(y)]<-y
  • return(w)
  • }))

ra<-seg[,1]/seg[,2]
Error in seg[, 1] : subscript out of bounds

and i think the Warning message:
Setting row names on a tibble is deprecated. is making the error subscript out of bounds for inproper matrix

Hi Andresrcs I was thinking to post just with the appropriate subject so that i will find a solution.

If I have manage to download the file correctly, I think you have a mess on your hands. This is what I get.

dat2  structure(list(ANT.HEIGHT = 2:15, LEAF.AREA = c("", "", "205,90", 
"197,63", "197,63", "205,90", "209,54", "-", "-", "195,02", "229,21", 
"205,35", "237,59", "207,41"), LEAF.WEIDTH = c("", "", "490,07", 
"398,10", "398,10", "490,07", "455,83", "-", "-", "424,61", "467,17", 
"466,54", "502,92", "452,42"), LEAF.LENGTH = c("", "", "9,19", 
"7,78", "7,78", "9,19", "8,00", "-", "-", "7,57", "9,40", "8,03", 
"9,00", "8,83"), DIAMETER = c("", "", "76,20", "72,96", "72,96", 
"76,20", "81,59", "-", "-", "79,80", "71,19", "82,60", "78,65", 
"74,03"), Markername = c("", "", "1,57", "1,79", "1,79", "1,57", 
"1,76", "-", "-", "1,36", "1,74", "1,58", "1,55", "1,60"), PZE.104090782 = c("", 
"", "PHM10", "PHBW8", "PHBW8", "PHM10", "DH107", "DH265", "DH376", 
"DH216", "DH236", "DH4", "DH70", "DH296"), SYN18784 = c("4", 
"166875919", "A", "B", "B", "A", "B", "A", "B", "A", "B", "B", 
"A", "A"), PZE.109052349 = c("9", "90367887", "A", "B", "B", 
"A", "B", "A", "A", "A", "B", "B", "A", "B"), PZE.109052348 = c("9", 
"90366825", "A", "B", "B", "A", "B", "A", "A", "A", "B", "B", 
"A", "B"), ZM013464.0223 = c("9", "90366747", "A", "B", "B", 
"A", "B", "A", "A", "A", "B", "B", "A", "B"), PZE.101178540 = c("10", 
"51680981", "A", "B", "B", "A", "B", "A", "B", "B", "A", "B", 
"B", "B"), PZE.102028584 = c("1", "223161749", "A", "B", "B", 
"A", "B", "B", "B", "A", "B", "B", "B", "A"), X = c("2", "13382024", 
"A", "B", "B", "A", "B", "B", "B", "B", "B", "A", "B", "B")), class = "data.frame", row.names = c(NA, 
-14L))

Those "-" are converting what should be numeric variables to character variables.  You are using a ","  as a decimal marker and R needs the decimal marker to be a "." .

You have columns SYN18784,	PZE-109052349,	PZE-109052348,	ZM013464-0223,	PZE-101178540,	PZE-102028584, with a mixture of numbers and characters.  Fore example 

SYN18784
4
166875919SYN18784
4
166875919
A
B
B
A
B
A
B
A
B
B
A
A

A
B
B
A
B
A
B
A
B
B
A
A

Is these intended to do character variables ?

I downloaded the dta to a spreadsheet, manually set the "-" cells to empty and saved as a .csv. I then read the data into are with

dat1 <- read.csv2("rami2.csv", sep = "\t")

and this is what I got.

dat1 <- structure(list(ANT.HEIGHT = 2:15, LEAF.AREA = c(NA, NA, 205.9,
197.63, 197.63, 205.9, 209.54, NA, NA, 195.02, 229.21, 205.35,
237.59, 207.41), LEAF.WEIDTH = c(NA, NA, 490.07, 398.1, 398.1,
490.07, 455.83, NA, NA, 424.61, 467.17, 466.54, 502.92, 452.42
), LEAF.LENGTH = c(NA, NA, 9.19, 7.78, 7.78, 9.19, 8, NA, NA,
7.57, 9.4, 8.03, 9, 8.83), DIAMETER = c(NA, NA, 76.2, 72.96,
72.96, 76.2, 81.59, NA, NA, 79.8, 71.19, 82.6, 78.65, 74.03),
Markername = c(NA, NA, 1.57, 1.79, 1.79, 1.57, 1.76, NA,
NA, 1.36, 1.74, 1.58, 1.55, 1.6), PZE.104090782 = c("", "",
"PHM10", "PHBW8", "PHBW8", "PHM10", "DH107", "DH265", "DH376",
"DH216", "DH236", "DH4", "DH70", "DH296"), SYN18784 = c("4",
"166875919", "A", "B", "B", "A", "B", "A", "B", "A", "B",
"B", "A", "A"), PZE.109052349 = c("9", "90367887", "A", "B",
"B", "A", "B", "A", "A", "A", "B", "B", "A", "B"), PZE.109052348 = c("9",
"90366825", "A", "B", "B", "A", "B", "A", "A", "A", "B",
"B", "A", "B"), ZM013464.0223 = c("9", "90366747", "A", "B",
"B", "A", "B", "A", "A", "A", "B", "B", "A", "B"), PZE.101178540 = c("10",
"51680981", "A", "B", "B", "A", "B", "A", "B", "B", "A",
"B", "B", "B"), PZE.102028584 = c("1", "223161749", "A",
"B", "B", "A", "B", "B", "B", "A", "B", "B", "B", "A"), X = c("2",
"13382024", "A", "B", "B", "A", "B", "B", "B", "B", "B",
"A", "B", "B")), class = "data.frame", row.names = c(NA,
-14L))


Does this data layout make any sense?

You have provided a sample of your csv file but, immediately after you read the csv file into the geno0 data frame you overwrite it with a subset of the bp object, rendering the sample data useless since it is not actually used in your code and we have no idea of what or from where the bp object comes from. Can you please check on that? Maybe you are not aware that you are overwriting your csv file's content, which is the cause of your problem.

About this, you can always edit your topic title to better represent your actual question or issue.

i wanted to overwrite it because i have a 2 rows duplicated to avoid them i wrote. the bp as my file (actually bp is 0_rawdata/RQTL_BO21_MT.csv file in r studio file)

Overwriting from an object in memory can break your code in subsequent sessions and certainly makes your code impossible to follow by others.

Also, the sample data you have provided have no duplicated rows on positions 3 and 4 and since we can't know the exact structure of bp, we can't follow along with your code. This is exactly why I asked you for a proper reproducible example, so we can all work on the same data and code.

in column f there are repeated PHM10, PHBW8, PHBW8, PHM10 so in geno0<-bp[-c(3,4),] say delete 3,4 column from the bp

f<-which(seg[,3]>10)
geno<-geno[,-f]

Ok, these two lines of code turn geno into an empty data frame, because there is no row in seg with H values over 10 so you are effectively subsetting by -0 i.e. geno[,-0], this is why you get the "subscript out of bounds" error. You can't subset positions that do not exist and an empty data frame has no positions at all.

You could check f length before subsetting

if (length(f)>0) {
    geno<-geno[,-f]
    map<-map[-f,]
}

If you are still skeptical and you still think the warning message has something to do with your problem somehow, then simply subset from the imported data instead of subsetting from bp (which is a tibble) and you would get rid of it. Although, you will still get the same error because of the reasons I already explained to you before.

geno0 <- read.csv('0_rawdata/RQTL_BO21_MT.csv')
geno0 <- geno0[-c(3,4),]

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.