IRanges object from count matrix
1
0
Entering edit mode
Assa Yeroslaviz ★ 1.5k
@assa-yeroslaviz-1597
Last seen 7 weeks ago
Germany

Hi,

is there a way to automatically convert the featureCounts result matrix into a GRanges (IRanges) object? by feeding it into GRanges?

I ran featureCounts for the data set and have this matrix (first 5 columns):

              Chr      Start        End  Strand Length
ENSMUSG00000102693    1    3073253    3074322    +   1070
ENSMUSG00000064842    1    3102016    3102125    +    110
ENSMUSG00000102851    1    3252757    3253236    +    480
ENSMUSG00000103377    1    3365731    3368549    -   2819
ENSMUSG00000104017    1    3375556    3377788    -   2233

When I am trying to do it, I get the following error, that GRanges can't understand negative values. I guess the problem occurs with the reverse strand where the start position is smaller than the end position of the gene. 

countsTable <- read.delim2(file = "../featureCounts/featureCounts.geneLevel.txt", 
                           header = TRUE, sep = "\t", quote = "", skip = 1, 
                           row.names = 1 )
geneRanges <- GRanges(seqnames = countsTable$Chr,
                      ranges = IRanges(start = as.numeric(countsTable$Start), 
                                       end = as.numeric(countsTable$End)),
                      strand = countsTable$Strand
)

Error in .Call2("solve_user_SEW0", start, end, width, PACKAGE = "IRanges") : 
  solving row 2: negative widths are not allowed

thanks in advance for any suggestions

Assa

 

genomicranges iranges featurecounts counts rnaseq • 1.6k views
ADD COMMENT
0
Entering edit mode
@herve-pages-1542
Last seen 7 days ago
Seattle, WA, United States

Hi Assa,

Looks like you have a data.frame, not a matrix. You can call makeGRangesFromDataFrame() on it to turn it into a GRanges object. You might want to call the function with keep.extra.columns=TRUE to preserve the Length column. See ?makeGRangesFromDataFrame for the details.

Note that the start/end of a genomic feature are always its 5' and 3' ends with respect to the plus strand, even for a feature that belongs to the minus strand. That means that the start position should always be smaller than the end position, whatever the strand is. The only exception to this is for a zero-length feature where end = start - 1.

H.

ADD COMMENT

Login before adding your answer.

Traffic: 535 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