Getting an error trying to do tximportData tutorial
1
0
Entering edit mode
mogasawara • 0
@mogasawara-18270
Last seen 5.4 years ago

Hello,

I am working through the "Analyzing RNA-seq data with DESeq2"  and have installed the 'tximportData' package. I am getting an error when I am setting the Factor; I've tried factor(), relevel() each individually and also both (which I'm assuming we wouldn't need to) but came across the same error whichever way. Would appreciate any help, thank you.

```{r}

dir <- system.file("extdata", package="tximportData")
samples <- read.table(file.path(dir,"samples.txt"), header=TRUE)
samples$condition <- factor(rep(c("A","B"),each=3))
rownames(samples) <- samples$run
samples[,c("pop","center","run","condition")]

files <- file.path(dir,"salmon", samples$run, "quant.sf.gz")
names(files) <- samples$run
tx2gene <- read_csv(file.path(dir, "tx2gene.gencode.v27.csv"))

txi <- tximport(files, type="salmon", tx2gene=tx2gene)
ddsTxi <- DESeqDataSetFromTximport(txi,
                                   colData = samples,
                                   design = ~ condition)
keep <-rowSums(counts(ddsTxi))>=10
ddsTxi<-ddsTxi[keep,]

ddsTxi$condition <- factor(ddsTxi$condition, levels = c("untreated","treated"))

dds<-DESeq(ddsTxi)
res<-results(dds)

```

```{r}
traceback()
sessionInfo()
```

3: stop("full model matrix is less than full rank")
2: designAndArgChecker(object, betaPrior)
1: DESeq(ddsTxi)

Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] DESeq2_1.22.1               SummarizedExperiment_1.12.0 DelayedArray_0.8.0          BiocParallel_1.16.0        
 [5] matrixStats_0.54.0          Biobase_2.42.0              GenomicRanges_1.34.0        GenomeInfoDb_1.18.0        
 [9] IRanges_2.16.0              S4Vectors_0.20.1            BiocGenerics_0.28.0         tximport_1.10.0            
[13] readr_1.1.1                 tximportData_1.10.0        

loaded via a namespace (and not attached):
 [1] bit64_0.9-7            jsonlite_1.5           splines_3.5.0          Formula_1.2-3          assertthat_0.2.0      
 [6] latticeExtra_0.6-28    blob_1.1.1             GenomeInfoDbData_1.2.0 yaml_2.2.0             RSQLite_2.1.1         
[11] pillar_1.3.0           backports_1.1.2        lattice_0.20-35        glue_1.3.0             digest_0.6.18         
[16] RColorBrewer_1.1-2     XVector_0.22.0         checkmate_1.8.5        colorspace_1.3-2       htmltools_0.3.6       
[21] Matrix_1.2-14          plyr_1.8.4             XML_3.98-1.16          pkgconfig_2.0.2        genefilter_1.64.0     
[26] zlibbioc_1.28.0        purrr_0.2.5            xtable_1.8-3           scales_1.0.0           htmlTable_1.12        
[31] tibble_1.4.2           annotate_1.60.0        ggplot2_3.1.0          nnet_7.3-12            lazyeval_0.2.1        
[36] survival_2.42-6        magrittr_1.5           crayon_1.3.4           memoise_1.1.0          foreign_0.8-70        
[41] tools_3.5.0            data.table_1.11.8      hms_0.4.2              stringr_1.3.1          locfit_1.5-9.1        
[46] munsell_0.5.0          cluster_2.0.7-1        AnnotationDbi_1.44.0   bindrcpp_0.2.2         compiler_3.5.0        
[51] rlang_0.3.0.1          grid_3.5.0             RCurl_1.95-4.11        rstudioapi_0.8         htmlwidgets_1.3       
[56] bitops_1.0-6           base64enc_0.1-3        gtable_0.2.0           DBI_1.0.0              R6_2.3.0              
[61] gridExtra_2.3          knitr_1.20             dplyr_0.7.7            bit_1.1-14             bindr_0.1.1           
[66] Hmisc_4.1-1            stringi_1.2.4          Rcpp_1.0.0             geneplotter_1.60.0     rpart_4.1-13          
[71] acepack_1.4.1          tidyselect_0.2.5      

deseq2 tximport • 815 views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 5 hours ago
United States

This step is the one generating the error:

ddsTxi$condition <- factor(ddsTxi$condition, levels = c("untreated","treated"))

If you take a look at ddsTxi$condition after you do this, you've made NAs. If you want to change the names of the levels, you shouldn't do this:

> x <- factor(c("A","B"))
> factor(x, levels=c("C","D"))
[1] <NA> <NA>
Levels: C D

Instead you should do:

> levels(x) <- c("C","D")
> x
[1] C D
Levels: C D
>

 

 

ADD COMMENT
0
Entering edit mode

Oh, I see, thank you very much. Yes, I did observe that NAs but I didn't understand that was the cause of my error. I was assuming that with the factor(), we could change the names. I was looking at the Conditions column that had "A" and "B" and so I thought for some reason it would change to "untreated" and "treated" as that's what was labeled in the results output. It also showed in my output that the names *didn't* change when I tried it, but I thought I was missing something. I appreciate your quick response! 

ADD REPLY

Login before adding your answer.

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