Error in 1:nrow(m): argument of length 0
Closed this issue · 3 comments
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
Also, fwiw, it's not the tbl_df
that's causing an issue - tried setting to as.data.frame(grch38_gt)
also. Same error.
This should fix it:
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