kbroman / qtl

R/qtl: A QTL mapping environment
https://rqtl.org
GNU General Public License v3.0
77 stars 45 forks source link

Initial commit of read.cross.tidy() #20

Closed aaronwolen closed 10 years ago

aaronwolen commented 10 years ago

Hi Karl,

This PR adds support for a new read.cross() format I'm calling "tidy" because genotype, phenotype and map data are stored in separate files using a standard data.frame-like format:

Phenotypes:

  1 2 3 4 5
T264 118.3 264 194.9 264 145.4

Genotypes:

  1 2 3 4 5
D10M44 B - - B H
D1M3 B B H B H
D1M75 B B H H H
D1M215 H B H H H
D1M309 H H H H B

Map:

  chr cm
D10M44 1 0
D1M3 1 0.996
D1M75 1 24.85
D1M215 1 40.41
D1M309 1 49.99

The advantage of this format is each file can be easily loaded into R with read.table() for analysis/visualization outside of R/qtl. For projects using R/qtl I usually maintain two sets of genotype/phenotype files: 1 for general analysis and 1 set formatted for R/qtl. Adding something like read.cross.tidy() would allow me to avoid that redundancy, so that's my selfish motivation behind this PR.

I'd call it draft code at this point; it works but lacks the extensive data checks found in the other read.cross.*() functions. I can bring it up to parity but wanted to gauge your level interest before proceeding.

kbroman commented 10 years ago

Great idea! I'll merge it into the devel branch. I'm reserving the master branch for the latest release.

aaronwolen commented 10 years ago

Cool! I'll integrate it with read.cross() and add some of the missing data checks. Let me know if you have any other suggestions.

aaronwolen commented 10 years ago

I made some improvements to the original PR:

I wrote a few simple tests to ensure a cross created with read.cross.tidy() is identical to one created with an existing read.cross.*() function and verify that cross data can be round tripped:

files -> `read.cross.tidy()` -> `write.cross.tidy()` -> files -> `read.cross.tidy()`

I didn't want to muck up your existing testing infrastructure so I kept my tests in a separate branch, which isn't part of this PR.

kbroman commented 10 years ago

Thanks, @aaronwolen! I've incorporated your code into the devel branch. I also added a test and added a small bit to the documentation for read.cross and write.cross.