Question: Subset SummarizedExperiment/GRangesList by seqnames
0
gravatar for Michael Love
4.3 years ago by
Michael Love24k
United States
Michael Love24k wrote:

I should really know this by now, but I can't recall how to cleanly subset a SummarizedExperiment/GRangesList by seqnames. 

Here I gave some bad example code just now, though I know there is something better:

C: remove X and Y chromosome genes in RNA-seq data using DESeq2 pipeline

I searched here first and found:

A: GRangesList filtering

But using Valerie's code there gives:

> grl[seqnames(grl) == "chr2"]

GRangesList object of length 3:
$gr1
GRanges object with 1 range and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr2    [3, 6]      *

$gr2
GRanges object with 0 ranges and 0 metadata columns:
     seqnames ranges strand

$gr3
GRanges object with 1 range and 0 metadata columns:
      seqnames ranges strand
  [1]     chr2 [4, 9]      *

Already, a better solution than my as.character() hack is to throw a elementLengths on top:

> elementLengths(grl[seqnames(grl) == "chr2"]) > 0
  gr1   gr2   gr3
 TRUE FALSE  TRUE

But there must be a better way I'm forgetting.

> sessionInfo()
R version 3.2.0 Patched (2015-04-26 r68264)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
Running under: OS X 10.8.5 (Mountain Lion)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats4    parallel  stats     graphics  grDevices datasets  utils     methods   base

other attached packages:
[1] GenomicRanges_1.20.3 GenomeInfoDb_1.4.0   IRanges_2.2.1        S4Vectors_0.6.0
[5] BiocGenerics_0.14.0  testthat_0.9.1       devtools_1.7.0       knitr_1.10
[9] BiocInstaller_1.18.1

loaded via a namespace (and not attached):
[1] XVector_0.8.0 tools_3.2.0
genomicranges • 1.2k views
ADD COMMENTlink modified 4.3 years ago by anpham0 • written 4.3 years ago by Michael Love24k
Answer: Subset SummarizedExperiment/GRangesList by seqnames
0
gravatar for Michael Love
4.3 years ago by
Michael Love24k
United States
Michael Love24k wrote:

Martin already answered this here:

C: remove X and Y chromosome genes in RNA-seq data using DESeq2 pipeline

ADD COMMENTlink written 4.3 years ago by Michael Love24k
Answer: Subset SummarizedExperiment/GRangesList by seqnames
0
gravatar for anpham
4.3 years ago by
anpham0
anpham0 wrote:

Thanks very much Michael and Martin.  I used the codes below to subset the dds object and it worked without any problem.

seqnames(dds)
dds.sub <- dds[ all(! seqnames(dds) %in%  c("chrX", "chrY"))]

ADD COMMENTlink written 4.3 years ago by anpham0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 249 users visited in the last hour