ying14 / yingtools2

Ying's tools for analysis, with particular focus on microbiome data
39 stars 7 forks source link

Few questions running Lefse #12

Closed zoreaj closed 4 years ago

zoreaj commented 5 years ago

Hey I am facing 2 major issues using the lefse wrapper function:

  1. after running lefse.tbl <- lefse2(cid.phy,class="Consistency") I got this warning message: Column sample joining factor and character vector, coercing into character vector

this led to the second issue when trying to plot it using the code :

lefse.tbl %>%

Can you help me understand what is going wrong?

ying14 commented 5 years ago

Do you actually get an error message at some point (i.e. not a warning)? Not sure but I don't think the 'coercing into character' warning is the issue. Moreover, the change you made to lefse.out <- ... actually makes it read in the wrong file at the end. Here is what the function is attempting to do:

  1. Creates lefse.txt (formatted input file)
  2. Executes format_input.py script to create lefse.in
  3. Executes run_lefse.py script on lefse.in to create lefse.res
  4. Reads in lefse.res as R data frame and does further formatting.

Does the function create all these files? For example, does the function create a lefse.in file but not a lefse.res? If so, then the issue likely occurs in step 3, where you might encounter a problem if you haven't installed all the necessary R packages. Again, look for error messages to see if this might be the case.

zoreaj commented 5 years ago

Thanks for the detailed message. Somehow, this morning it were able to create the lefse.res file (attached) for my data however, following the next plotting part: lefse.tbl %>% filter(!is.na(lda),lda>1,direction %in% c("Tramatinib_sensitive","no_treatment")) %>% mutate(lda=ifelse(direction=="Tramatinib_resistance",-lda,lda)) %>% ggplot() +

geom_bar(aes(x=reorder(taxon,lda),y=lda,fill=direction),color="black",stat="identity") + coord_flip()

I get a blank graph (attached). I did repeat it with cid94 results with no better outcome What goes wrong? [image: image.png]

‫בתאריך יום ד׳, 11 בספט׳ 2019 ב-19:42 מאת ‪Ying Taur‬‏ <‪ notifications@github.com‬‏>:‬

Do you actually get an error message at some point (i.e. not a warning)? Not sure but I don't think the 'coercing into character' warning is the issue. Moreover, the change you made to lefse.out <- ... actually makes it read in the wrong file at the end. Here is what the function is attempting to do:

  1. Creates lefse.txt (formatted input file)
  2. Executes format_input.py script to create lefse.in http://lefse.in
  3. Executes run_lefse.py script on lefse.in http://lefse.in to create lefse.res
  4. Reads in lefse.res as R data frame and does further formatting.

Does the function create all these files? For example, does the function create a lefse.in http://lefse.in file but not a lefse.res? If so, then the issue likely occurs in step 3, where you might encounter a problem if you haven't installed all the necessary R packages. Again, look for error messages to see if this might be the case.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ying14/yingtools2/issues/12?email_source=notifications&email_token=ANCXSKMNWIIVNNVM26SJHZTQJENXLA5CNFSM4IVTKJ5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6PD34Y#issuecomment-530464243, or mute the thread https://github.com/notifications/unsubscribe-auth/ANCXSKJPXOM5I7TI3EVCPTTQJENXLANCNFSM4IVTKJ5A .

Joyce2896 commented 5 years ago

Hi Ying14,

I've faced a problem using the lefse wrapper function. Trying to replicate using your data CID94. The error occur as shown below. Any idea whats' wrong here, pretty sure i put in the correct folder.

setwd("C:/~/phyloseq/nsegata-lefse-9adc3a62460e/nsegata-lefse-9adc3a62460e") lefse.tbl <- lefse2(cid.phy,class="Consistency") [1] "Wrote lefse.res" Error in file(file, "rt") : cannot open the connection In addition: Warning messages: 1: Column sample joining factor and character vector, coercing into character vector 2: In file(file, "rt") :

ying14 commented 4 years ago

zoreaj, Do you have the lefse.res file? I didn't see any attachment above.

ying14 commented 4 years ago

Joyce2896, See the above discussion, what files are created? You are looking to see if lefse.txt, lefse.in, and lefse.res is successfully created.

Joyce2896 commented 4 years ago

Ying14, I've only seen lefse.txt file created in my directory file, without any lefse.in and lefse.res

zoreaj commented 4 years ago

I attached the file here Thanks a lot for the help

בתאריך יום ה׳, 3 באוק׳ 2019, 2:32, מאת Ying Taur ‏<notifications@github.com

:

zoreaj, Do you have the lefse.res file? I didn't see any attachment above.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ying14/yingtools2/issues/12?email_source=notifications&email_token=ANCXSKLCXB5SRVYM2IZBIGDQMUVRFA5CNFSM4IVTKJ5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAGQIMI#issuecomment-537723953, or mute the thread https://github.com/notifications/unsubscribe-auth/ANCXSKPVNIZTVG5BRPJMEOTQMUVRFANCNFSM4IVTKJ5A .

ying14 commented 4 years ago

zoreaj sorry I still don't see the file. I need to see if the file is well-formed... basically it should look somethhing like this:

Bacteria.Planctomycetes.Planctomycetacia.Planctomycetales.Planctomycetaceae.Pirellula.Other_Bacteria    0.281641221631          -
Bacteria.Actinobacteria.Actinobacteria.Coriobacteriales.Coriobacteriaceae   4.07035473066   formed stool    3.78867885981   1.06659880665e-06
Bacteria.Acidobacteria.Acidobacteria_Gp4.Gp4.unclassified.unclassified.Other_Bacteria   0.356347995133          -
Bacteria.Firmicutes.Clostridia.Clostridiales.Eubacteriaceae 3.13365126013   formed stool    2.81296591873   0.00645493179017
<...>
ying14 commented 4 years ago

Joyce2896, It sounds like lefse did not execute correctly. Can you confirm that you can successfully run python format_input.py -h from your operating system command line, in that folder?

Joyce2896 commented 4 years ago

Hi Ying14, I run the command line with python format_input.py Script. It shows me the following, i did not see any file created or error message. system("python format_input.py")

I tried another time to rerun your script. Maybe the error begins way earlier, started with error it could not find function "data.table", so i call in the library ("data.table") but to no avail.

lefse.tbl <- lefse(cid.phy, class = "Consistency") Error in data.table(otutab, keep.rownames = TRUE) : could not find function "data.table" library("data.table", lib.loc="~/R/R-3.5.1/library") data.table 1.12.2 using 2 threads (see ?getDTthreads). Latest news: r-datatable.com

Attaching package: ‘data.table’

The following objects are masked from ‘package:dplyr’:

between, first, last

The following object is masked from ‘package:SummarizedExperiment’:

shift

The following object is masked from ‘package:GenomicRanges’:

shift

The following object is masked from ‘package:IRanges’:

shift

The following objects are masked from ‘package:S4Vectors’:

first, second

Warning message: package ‘data.table’ was built under R version 3.5.3

lefse.tbl <- lefse(cid.phy, class = "Consistency") [1] "Wrote lefse.res" Error in file(file, "rt") : cannot open the connection In addition: Warning messages: 1: Column sample joining factor and character vector, coercing into character vector 2: select_() is deprecated. Please use select() instead

The 'programming' vignette or the tidyeval book can help you to program with select() : https://tidyeval.tidyverse.org This warning is displayed once per session. 3: In file(file, "rt") :

Show Traceback

Rerun with Debug Error in file(file, "rt") : cannot open the connection

elittmann commented 4 years ago

Joyce2896,

When you run system("python format_input.py") you should see the options for the lefse command appear in the console. If you don't there's an issue with your installation of lefse

Thanks, -Eric