Closed aminards closed 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
GRset.funnorm.tissues
column names is also equal to GRset.funnorm.tissues$Sample_ID
, then just write GRset.funnorm.tissues[,tissuesamples]
colnames(GRset.funnorm.tissues) <- GRset.funnorm.tissues$Sample_ID
, and then follow the above instruction@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.
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?