hansenlab / minfi

Devel repository for minfi
60 stars 70 forks source link

How can I subset a GenomicRatioSet? #192

Closed aminards closed 5 years ago

aminards commented 5 years ago

I have a genomic ratio set normalized using functional normalization, GRset.funnorm. I want to collect a subset of the samples for further analysis. I have a vector of my Sample_ID of interest and my GRset.funnorm has $Sample_ID under @colData.

I have tried a few methods which all give errors:

library(dplyr) GRset.funnorm.tissues <- GRset.funnorm %>% filter(SampleID == tissuesamples) Error in UseMethod("filter") : no applicable method for 'filter_' applied to an object of class "c('GenomicRatioSet', 'RangedSummarizedExperiment', 'SummarizedExperiment', 'Vector', 'Annotated')" and

GRset.funnorm.tissues <- subset(GRset.funnorm, GRset.funnorm$Sample_ID == tissuesamples) Warning message: In GRset.funnorm$Sample_ID == tissuesamples : longer object length is not a multiple of shorter object length

How can I subset my genomicRatioSet based on the Sample IDs?

wvictor14 commented 5 years ago

This is a basic data manipulation task.

You cannot apply dplyr::filter because dplyr functions only work on data.frame objects. Genomic ratio sets are not data.frames but a special type of object of it's own. You can subset it the "normal" (base-r) way with square brackets [].

If your vector of interest is tissuesamples, and they all are within GRset.funnorm.tissues$Sample_ID then if

aminards commented 5 years ago

@wvictor14 Thank you for your explanation and the code snippets to achieve my task. I ended up having to first set the column names and then get the subset as you described in you second option.