Salmon (quant.sf) to tximport error
1
0
Entering edit mode
Merlin ▴ 10
@merlin-15723
Last seen 4.2 years ago
Vancouver

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 • 1.9k views
ADD COMMENT
1
Entering edit mode
@mikelove
Last seen 2 hours ago
United States

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.

ADD COMMENT
0
Entering edit mode

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"

  > txi.salmon <-tximport(salmonfiles, type="salmon", tx2gene = tx2gene, reader=read_tsv)
    Error in tximport(salmonfiles, type = "salmon", tx2gene = tx2gene, reader = read_tsv) : 
      unused argument (reader = read_tsv)
    >

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

thank you

ADD REPLY
0
Entering edit mode

Probably an old version of Bioconductor.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Back to the beginning.

Just don’t specify “reader”. The function is telling you that it doesn’t know about “reader”.

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

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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"))

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

ADD REPLY
1
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

Ok Michael, I will follow your suggestion

Thanks

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Hi Merlin,

I am the new guy to bioinformatic in general and R too. and i come across the similar problem. Can you post your final solution to this problem? Really appreciate.

ADD REPLY

Login before adding your answer.

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