Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in 1:nrow(m): argument of length 0 #4

Closed
stephenturner opened this issue Dec 8, 2015 · 3 comments
Closed

Error in 1:nrow(m): argument of length 0 #4

stephenturner opened this issue Dec 8, 2015 · 3 comments

Comments

@stephenturner
Copy link

I get the error Error in 1:nrow(m): argument of length 0 when trying to import either kallisto or sailfish output. Here's a reprex.


Load packages used here.

library(dplyr)
library(readr)
library(tximport)
library(annotables) # devtools::install_github(stephenturner/annotables)

To summarize transcripts to the gene level we'll need to use a transcript-to-gene annotation. I provide this in the annotables package (blog post; install from github with devtools::install_github("stephenturner/annotables")). The grch38_gt table contains mappings for 216133 transcripts to 65988 genes.

annotables::grch38_gt
## Source: local data frame [216,133 x 2]
## 
##            ensgene          enstxp
##              (chr)           (chr)
## 1  ENSG00000210049 ENST00000387314
## 2  ENSG00000211459 ENST00000389680
## 3  ENSG00000210077 ENST00000387342
## 4  ENSG00000210082 ENST00000387347
## 5  ENSG00000209082 ENST00000386347
## 6  ENSG00000198888 ENST00000361390
## 7  ENSG00000210100 ENST00000387365
## 8  ENSG00000210107 ENST00000387372
## 9  ENSG00000210112 ENST00000387377
## 10 ENSG00000198763 ENST00000361453
## ..             ...             ...

Download data from here: https://dl.dropboxusercontent.com/u/66281/sailfish-txps.txt to data/ directory. Take a look at what the file looks like:

readLines("data/sailfish-txps.txt", n=20)
##  [1] "# sailfish (quasi-mapping-based) v0.7.6"        
##  [2] "# [ program ] => sailfish "                     
##  [3] "# [ command ] => quant "                        
##  [4] "# [ index ] => { sailfish-grch38-index }"       
##  [5] "# [ libType ] => { IU }"                        
##  [6] "# [ threads ] => { 3 }"                         
##  [7] "# [ geneMap ] => { Homo_sapiens.GRCh38.82.gtf }"
##  [8] "# [ mates1 ] => { SRR493366_1.fastq }"          
##  [9] "# [ mates2 ] => { SRR493366_2.fastq }"          
## [10] "# [ output ] => { SRR493366-sfem }"             
## [11] "# [ mapping rate ] => { 95.2197% }"             
## [12] "# Name\tLength\tTPM\tNumReads"                  
## [13] "ENST00000415118\t8\t0\t0"                       
## [14] "ENST00000448914\t13\t0\t0"                      
## [15] "ENST00000631435\t12\t0\t0"                      
## [16] "ENST00000434970\t9\t0\t0"                       
## [17] "ENST00000632684\t12\t0\t0"                      
## [18] "ENST00000431440\t16\t0\t0"                      
## [19] "ENST00000454691\t18\t0\t0"                      
## [20] "ENST00000451044\t17\t0\t0"

Try importing:

sf <- tximport("data/sailfish-txps.txt", type="salmon", gene2tx=grch38_gt)
## Error in 1:nrow(m): argument of length 0
@stephenturner
Copy link
Author

Also, fwiw, it's not the tbl_df that's causing an issue - tried setting to as.data.frame(grch38_gt) also. Same error.

@mikelove
Copy link
Collaborator

mikelove commented Dec 8, 2015

This should fix it:

1648def

it's the classic gotcha of, with a matrix with one dimension of length 1, without drop=FALSE, R converts a matrix to a vector

@mikelove
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants