problems reading map positions in a 4way cross.

97 views
Skip to first unread message

joe....@gmail.com

unread,
Mar 20, 2019, 12:32:55 PM3/20/19
to R/qtl discussion
I'm having trouble with read.cross() for type "4way", reading from a 'csvr' file. I get the error

1: In summary.cross(cross) :
The genetic maps should all be matrices with two rows.

Currently, I have my data formatted so that;
Col1 = markername
Col2 = chromosome id
Col3 = male map position
Col4 = female map position

(sample below)

But clearly this is not what read.cross() expects. I am unable to find any examples of a 'correctly formatted' 4way cross anywhere, and write.cross() will not allow the export of 4way crosses to csv format, so I can't see the correct way to format this so that read.cross() can read it as a matrix with two rows.

Any help would be appreciated.

test <- read.cross('csvr','.', 'test.txt', genotypes=NULL, estimate.map=FALSE, crosstype="4way")

head test.txt
id,,,,a,b,c,d,e,f
sex,,,,0,1,1,1,1,1,0,1,0,0,1,1,0,0,0
phe,,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
CHR2_288112,2,0.000,0.000,1,4,3,2,1,4
CHR2_334258,2,1.093,0.000,2,4,3,2,1,4
CHR2_334268,2,1.300,0.000,2,4,3,2,1,4
CHR2_455684,2,3.195,0.000,2,4,3,2,1,4
CHR2_517129,2,3.195,0.000,2,4,3,2,1,4
CHR2_740302,2,4.663,0.000,2,4,3,2,1,4

Karl Broman

unread,
Mar 20, 2019, 12:35:22 PM3/20/19
to rqtl...@googlegroups.com
It will only take a single set of sex-averaged positions. You’re unfortunately on your own to get sex-specific positions in there.

sorry,
karl
> --
> You received this message because you are subscribed to the Google Groups "R/qtl discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rqtl-disc+...@googlegroups.com.
> To post to this group, send email to rqtl...@googlegroups.com.
> Visit this group at https://groups.google.com/group/rqtl-disc.
> For more options, visit https://groups.google.com/d/optout.

joe....@gmail.com

unread,
Mar 20, 2019, 12:48:14 PM3/20/19
to R/qtl discussion
Hi Karl, sorry but I don't understand your response. You say it will only take a single set of sex-averaged positions, but giving just one column still gives the error

Warning messages:

1: In summary.cross(cross) :
  The genetic maps should all be matrices with two rows.


and if you try to run calc.genoprob(), the error message

Error in map[1, ] : incorrect number of dimensions

so clearly it is expecting a matrix of two points. I can see that this is not achieved by having an extra column in the csvr file, but if not like that, how does read.cross() expect the data to be formatted so that it is a matrix with two rows?

Karl Broman

unread,
Mar 20, 2019, 1:15:08 PM3/20/19
to rqtl...@googlegroups.com
This is a bug. At the stage where the genetic map is supposed to be turned into a two-row matrix, it thinks the data are from cross type "f2" and so doesn't fix things properly.

A temporary fix is to read in the data with read.cross and then do:

for(i in seq_along(test$geno)) {
test$geno[[i]]$map <- rbind(test$geno[[i]]$map, test$geno[[i]]$map)
}

karl

joe....@gmail.com

unread,
Mar 20, 2019, 1:21:50 PM3/20/19
to R/qtl discussion
Karl, you're a legend! Thanks so much for the fix.

Noemie VT

unread,
Feb 28, 2021, 5:50:23 PM2/28/21
to R/qtl discussion
Hi Karl,

I am having a similar problem with reading in my 4way cross, however the temporary fix does not seem to work for me. 
Here is the first few lines and column of my input

wei_nov17 trevally000070_2842923 trevally000070_9235894 trevally000070_9932163 trevally000070_1677914 trevally000070_4785258
1 1 1 1 1
0 1.714 2.279 2.844 3.409
39 BD BD BD BD BD
115 BD BD BD BD BD
86 BC BC BC BC BC
138 AD AD AD AD AD
179 AC AC AC AC AC
144 AD AD AD AD AD

Any idea what is going wrong?

Karl Broman

unread,
Feb 28, 2021, 5:51:57 PM2/28/21
to rqtl...@googlegroups.com
Can you give more information about your problem? What code are you using to read the file, and what errors are you getting?

karl

Noemie VT

unread,
Mar 1, 2021, 9:24:21 PM3/1/21
to R/qtl discussion
Of course!

This is how I read the data:
tre  <- read.cross(format = "csv", "path",
                  "hgt25_nov17.csv", na.strings=c("NA"),  genotypes=c("AC","AD","BC","BD"),
                  estimate.map = F, crosstype="4way")

And this is the message I get:
--Read the following data: 
 89 individuals 
 1830 markers 
 1 phenotypes 
 --Cross type: 
4way 
 Warning message: In summary.cross(cross) : The genetic maps should all be matrices with two rows.

What's funny is that this input file work a few months ago, I've just gone back to get some info I forgot to write down and it looks like something got corrupted in the mean time..
Let me know if you'd like me to send you the full file

Thanks for the help

Noemie

Karl Broman

unread,
Mar 1, 2021, 9:33:51 PM3/1/21
to R/qtl discussion

Yes I would need to see the data file to figure out what the problem is.
What version of R and R/qtl are you using?

karl

Karl Broman

unread,
Mar 1, 2021, 10:18:51 PM3/1/21
to R/qtl discussion
I’ll take a look, but I’d definitely recommending upgrading both R (now 4.0.4) and R/qtl (now 1.47-9). The problem earlier in this thread was something that got fixed in the more recent version of the package.

karl
Reply all
Reply to author
Forward
0 new messages