Subsetting an existing cross2 object for select sample id's

39 views
Skip to first unread message

Mark Sfeir

unread,
Jun 29, 2022, 4:18:51 PM6/29/22
to R/qtl2 discussion
One main question in this post, along with some of my related considerations/uncertainties below it:

1) Is there a way to pass a vector of sample id's to calc_genoprob() in order to include only a selection of all the sample id's contained among the cross2 object's entries in the conditional genoprobability calculations (and subsequent qtl2 analysis)? 

I noticed calc_genoprob takes the whole cross2 object as input, so it's unclear how to cleanly subset its entries outside of creating a new cross2 object.

There are some cases in which being able to do so may be useful for my lab (to exclude certain mice from a different generation or that don't have the same set of phenotype data, for instance), rather than reconfiguring/subsetting the initial data files for a new cross2 object. 

Assuming I'm correct that it is at the step of calculating the LOD scores after calculating the conditional genotype probabilities that the different samples' genetic information first gets combined into a composite metric (the LOD scores reflecting each sample's contributions), it would not necessarily pose statistical or other data problems to subset the samples in this way (at the step of using calc_genoprob, that is).

Using fewer samples in the analysis is its own limitation, but for some uses it may be convenient and informative to be able to work with a subset. 

For reference/a workaround, here is a function I implemented to try to subset the relevant cross2 entries by sample, though by using lapply, it only returns a list object rather than an object of cross2. Maybe giving this new list object—which mirrors the original cross2 object's structure—the right cross2 attributes using the original cross2 object would be easy, but I don't know exactly what steps would be needed to coerce the list's class to cross2 so it could be operated on by qtl2. If you have some guidance on this, that could be helpful, too! 

-Mark


subsetting_cross2_obj.R

Karl Broman

unread,
Jun 29, 2022, 4:38:53 PM6/29/22
to R/qtl2 discussion
There's a function subset.cross2 for subsetting cross2 objects by individuals and/or chromosomes.
You can also use square brackets, like cross2[ind, chr] or cross2[ind, ]

karl
Reply all
Reply to author
Forward
0 new messages