Question: Salmon (quant.sf) to tximport error
0
28 days ago by
Merlin 10
Italy
Merlin 10 wrote:

Hello everyone,

I generated quant.sf files with salmon tool and now I want to import them into R and later perform a differential expression analysis. I'm following the procedure in this link Salmon/Sailfish

the first code is

files <- file.path(/home/RNAseq/salmon_folder/salmonSFquant/treated_1/quant.sf, /home/RNAseq/salmon_folder/salmonSFquant/treated_2/quant.sf, /home/RNAseq/salmon_folder/salmonSFquant/treated_3/quant.sf,
/home/RNAseq/salmon_folder/salmonSFquant/untreated_1/quant.sf, /home/RNAseq/salmon_folder/salmonSFquant/untreated_2/quant.sf, /home/RNAseq/salmon_folder/salmonSFquant/untreated_3/quant.sf,"salmon"
,samples$run, "quant.sf")  for some reason I have this error files <- file.path(/home/RNAseq/salmon_folder/salmonSFquant/treated_1/quant.sf, /home/RNAseq/salmon_folder/salmonSFquant/treated_2/quant.sf, /home/RNAseq/salmon_folder/salmonSFquant/treated_3/quant.sf, Error: unexpected '/' in "files <- file.path(/" > /home/RNAseq/salmon_folder/salmonSFquant/untreated_1/quant.sf, /home/RNAseq/salmon_folder/salmonSFquant/untreated_2/quant.sf, /home/RNAseq/salmon_folder/salmonSFquant/untreated_3/quant.sf,"salmon" Error: unexpected '/' in " /" > ,samples$run, "quant.sf")
Error: unexpected ',' in "                   ,"


Do I have to create a sample.txt?

I'm new to bioinformatic in general and R too, so I would appreciate any help,

thank you

tximport • 104 views
modified 28 days ago by Michael Love23k • written 28 days ago by Merlin 10
Answer: Salmon (quant.sf) to tximport error
1
28 days ago by
Michael Love23k
United States
Michael Love23k wrote:

In order to notify a maintainer, one of the tags for the post should be the name of the package, and tags need to be separated by comma. I happened to catch this post just looking through recent posts.

The error above actually gives you a pretty good clue:

files <- file.path(/home/RNAseq/salmon_folder/salmonSFquant/treated_1/quant.sf, /home/RNAseq/salmon_folder/salmonSFquant/treated_2/quant.sf, /home/RNAseq/salmon_folder/salmonSFquant/treated_3/quant.sf,


It says:

Error: unexpected '/' in "files <- file.path(/"


So R didn't expect a backslash where you put it, e.g. the first backslash caused a problem:

files <- file.path(/home...


Now compare your code to the code in the tximport vignette, or examples in the man pages.

Hi Michael, next time I will put the name of the package in the tag. I just use the tilda sign and I solved the issue... thanks :)

can I ask you for another help? I should be close to DESeq2 ...

> head(files)
character(0)

> salmonfiles <- paste0("sample", 1:6)
> salmonfiles
[1] "sample1" "sample2" "sample3" "sample4" "sample5" "sample6"

Error in tximport(salmonfiles, type = "salmon", tx2gene = tx2gene, reader = read_tsv) :
>


Can you tell me why I do have the error for reader=read_tsv, is it missing something?

thank you

Probably an old version of Bioconductor.

biocLite("BiocUpgrade") Error: Bioconductor version 3.8 cannot be upgraded with R version 3.5.0 In addition: Warning message: 'biocLite' is deprecated. Use 'BiocManager::install' instead. See help("Deprecated")

I hope is not for that,

thank you Michael

Back to the beginning.

And read help locally: ?tximport, vignette(“tximport”)

If you read help online and have out of date software you will get confused.

Hi Michael, I tried as you suggested to me but it didn't work .. so I start looking on the web for the solution without success. I have to say that when I write every path I check using the autocompletion if it's ok but this tool does't like my files. I ended up to do this pipeline:

 samples <- read.table(file.path("~RNAseq/salmon_folder/salmonSFquant/samples.txt"), header=TRUE)

samples
condition
1   treated1
2   treated2
3   treated3
4 untreated1
5 untreated2
6 untreated3


.

 files <- file.path("salmon", samples$run, "~RNAseq/salmon_folder/salmonSFquant/treated_1/quant.sf", "~RNAseq/salmon_folder/salmonSFquant/treated_2/quant.sf", "~RNAseq/salmon_folder/salmonSFquant/treated_3/quant.sf", "~RNAseq/salmon_folder/salmonSFquant/untreated_1/quant.sf", "~RNAseq/salmon_folder/salmonSFquant/untreated_2/quant.sf", "~RNAseq/salmon_folder/salmonSFquant/untreated_3/quant.sf") files character(0)  . condition<- paste0(samples$run)
condition


Is it correct this command line below like this? probably is this the problem

tx2gene <- read.csv(file.path("~RNAseq/salmon_folder/gencode.v29.transcripts.csv"))


I run this command below to se if he recognizes my files but I get 0

file.exists(files)
logical(0)


.

 txi <- tximport("files", type="salmon", tx2gene=tx2gene)

Error in tximport("files", type = "salmon", tx2gene = tx2gene) :
all(file.exists(files)) is not TRUE


I can't figure it out what's wrong, I would be more then happy to figure this out

thank you

That last error says that files is not pointing to files that exist at the location you specified.

You can just look at files and check that those are correct locations.

We are just checking,

file.exists(files)


internally to make sure the user is pointing to files that exist and can be read into R.

if I do

files


I have this

files character(0)

I'm sure that the files quant.sf are in the location of the path used

thank you

Ok if you look above you are trying to build a path using samples$run. But look at samples, does this have a column named run? You have to be careful about your R code and make sure that you are doing sensible things at each step. You can't refer to a column of a table that doesn't exist. ADD REPLYlink written 24 days ago by Michael Love23k To be honest with you I though that$run was a function of R, I learned something more, thanks. I did some adjustment, I have different results but still the same error...

    files <- file.path("salmon", samples\$condition,
"~RNAseq/salmon_folder/salmonSFquant/treated_1/quant.sf",
"~RNAseq/salmon_folder/salmonSFquant/treated_2/quant.sf",
"~RNAseq/salmon_folder/salmonSFquant/treated_3/quant.sf",
"~RNAseq/salmon_folder/salmonSFquant/untreated_1/quant.sf",
"~RNAseq/salmon_folder/salmonSFquant/untreated_2/quant.sf",
"~RNAseq/salmon_folder/salmonSFquant/untreated_3/quant.sf")


files [1] "salmon/treated1/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated1/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated2/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated3/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated1/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated2/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated3/quant.sf"
[2] "salmon/treated2/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated1/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated2/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated3/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated1/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated2/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated3/quant.sf"
[3] "salmon/treated3/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated1/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated2/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated3/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated1/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated2/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated3/quant.sf"
[4] "salmon/untreated1/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated1/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated2/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated3/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated1/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated2/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated3/quant.sf" [5] "salmon/untreated2/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated1/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated2/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated3/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated1/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated2/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated3/quant.sf" [6] "salmon/untreated3/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated1/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated2/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/treated3/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated1/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated2/quant.sf/~p.panelli/RNAseq/salmonfolder/salmonSFquant/untreated3/quant.sf"

names(files) <- paste0("sample",1:6)


names(files) <- paste0("sample",1:6) names(files) [1] "sample1" "sample2" "sample3" "sample4" "sample5" "sample6"

tx2gene <- read.csv(file.path("~RNAseq/salmon_folder/gencode.v29.transcripts.csv"))


txi <- tximport("files", type="salmon", tx2gene=tx2gene)


Error in tximport("files", type = "salmon", tx2gene = tx2gene) : all(file.exists(files)) is not TRUE

Thank you Michael

1

This is not really an issue with tximport but with working with R and specifying files. I have limited time unfortunately to reply to support requests here, essentially I have to carve it out of my spare time. I’d recommend sitting with a bioinformatician who can look over your shoulder and give some advice on avoiding small coding errors.

Thanks

Ok I fixed the problem,

I modified the codes, mainly by writing the entire paths for all the codes and fixing the variable file.path.

all(file.exists(files))


[1] TRUE