0

I am trying to make a Granges object with a list of genes that I have downloaded from MGI.

This is the column with strand info > mm9genes$X.3 gives me Levels: - +

However, when I use this code..

`GRanges(seqnames = Rle("chr12", 322),
               ranges = IRanges(start = mm9genes$X, end = mm9genes$X.1),
               strand = Rle(mm9genes$X.3),
               symbol = mm9genes$X.2)`

I get error Error in .local(x, ...) : invalid strand levels in 'x': - , + I am pretty new to this and trying to learn from. Will appreciate any help.

PDM
  • 84
  • 10
  • Please read [How to make a great R reproducible example?](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – M-- Apr 15 '17 at 22:50

1 Answers1

0

I figured out what was the problem.

with library(GenomicRanges) strand(mm9genes$X.3) Error in .local(x, ...) : invalid strand levels in 'x': - , +

A quick check gives

str(mm9genes$X.3) Factor w/ 3 levels "-","- ","+ ": 1 3 3 2 2 2 3 2 2 2 ...

So I trim the whitespaces after - $ +with library(stringr) mm9genes$X.3 <- str_trim(mm9genes$X.3)

following advices and here. Now, the following works.

GRanges(seqnames = Rle("chr12", 322), ranges = IRanges(start = mm9genes$X, end = mm9genes$X.1), strand = mm9genes$X.3, symbol = mm9genes$X.2)

Community
  • 1
  • 1
PDM
  • 84
  • 10