Subsetting GRanges objext
1
0
Entering edit mode
@lalchungnungabt17-16075
Last seen 4.0 years ago

Hi,

I have a GRanges object "MB_granges" which has data from Chr1 - Chr22, also ChrX and ChrY. I had removed ChrX and ChrY using the following command. 

> seqnames(MB_granges)
factor-Rle of length 485512 with 24 runs
  Lengths: 46857 34810 25159 20464 24327 36611 30017 20950  9861 24388 ... 21969 27879  5922 25521 10379  4243  8552 11232   416
  Values :  chr1  chr2  chr3  chr4  chr5  chr6  chr7  chr8  chr9 chr10 ... chr16 chr17 chr18 chr19 chr20 chr21 chr22  chrX  chrY
Levels(24): chr1 chr2 chr3 chr4 chr5 chr6 chr7 chr8 chr9 chr10 ... chr15 chr16 chr17 chr18 chr19 chr20 chr21 chr22 chrX chrY

>Desired_seqnames=c("chr1","chr2","chr3","chr4","chr5","chr6","chr7","chr8","ch9","chr10","chr11","chr12","chr13","chr14","chr15","chr16","chr17","chr18","chr19","chr20","chr21","chr22")

>New_MB_granges=subset(MB_granges, seqnames %in% Desired_seqnames)

But, when i check the sequence name of the new GRanges object, ChrX and ChrY still appears at the Levels, even though i was able to remove ChrX and ChrY. Can i get help how to get rid of this? I guess it might create problems later on. OR is this the correct way of subsetting a GRanges object?

seqnames(New_MB_granges)

factor-Rle of length 464003 with 21 runs
  Lengths: 46857 34810 25159 20464 24327 36611 30017 20950 24388 28794 ... 15078 15259 21969 27879  5922 25521 10379  4243  8552
  Values :  chr1  chr2  chr3  chr4  chr5  chr6  chr7  chr8 chr10 chr11 ... chr14 chr15 chr16 chr17 chr18 chr19 chr20 chr21 chr22
Levels(24): chr1 chr2 chr3 chr4 chr5 chr6 chr7 chr8 chr9 chr10 ... chr15 chr16 chr17 chr18 chr19 chr20 chr21 chr22 chrX chrY

 

Thank you in advance!

GRanges subsetting • 1.2k views
ADD COMMENT
1
Entering edit mode
@michael-lawrence-3846
Last seen 3.1 years ago
United States

This is the way factors work, and the behavior can be useful. To adjust the seqlevels, use a convenience function like keepSeqlevels(), or the seqlevels<-() setter.

ADD COMMENT

Login before adding your answer.

Traffic: 666 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6