Meredith-Lab / volcalc

volcalc: Calculate Volatility of Chemical Compounds
https://meredith-lab.github.io/volcalc/
Other
4 stars 1 forks source link

`calc_vol()` errors with 'could not find function `attomcount2tibble`' #105

Closed VaishChar closed 5 months ago

VaishChar commented 5 months ago

I tried uninstalling and reinstalling R. My R version is 4.3.3. and all the packages are up to date. I also used uploaded libraries ChemmineR, ChemmineOB, and KEGGREST. At the last step of the example, I receive this error- Error in atomcount2tibble(ChemmineR::atomcount(compound_sdf)) : could not find function "atomcount2tibble" (I can upload the R file if necessary)

If I only use the R code on the https://meredith-lab.github.io/volcalc/ I get these errors- Open Babel Error in GetStringValue InChIFormat is not loaded in R

curl::curl_fetch_memory(url, handle = handle) Failure when receiving data from the peer

Thank you for helping inadvance

Aariq commented 5 months ago

Thanks for using volcalc and reporting this!

1) regarding the atomcount2tibble() error, I'm not sure what would cause this. Can you share the code you used to get this error?

2) regarding the Open Babel Error—are you on Windows by any chance? The version of Open Babel bundled with ChemmineOB is not able to generate InChI (https://github.com/girke-lab/ChemmineOB/issues/37#issuecomment-2008364855), but this shouldn't be an issue for volcalc as it does not use InChI. Unfortunately there isn't a way to silence these Open Babel errors about InChI generation and you'll just have to ignore them.

3) I'm assuming the curl error happened when running get_mol_kegg(), is that correct? Do you get this error consistently? It could be that the KEGG API was down temporarily when you ran this, or that your internet connection was interrupted during download. If this persists, let me know and I can look into it.

Aariq commented 5 months ago

The curl error could also have come up because of downloading to a temporary directory. If you change the out_path in the example you might have better luck. E.g.

files <- get_mol_kegg(c("C16181", "C00042"), dir ="path/to/download/folder")
VaishChar commented 5 months ago

Hello Eric, It is nice to e-meet you!

  1. regarding the atomcount2tibble() error, I'm not sure what would cause this. Can you share the code you used to get this error?

I have attached my .rmd file to this email. I had to download and run all the other branches of the code since I was receiving a curl error initially.

  1. regarding the Open Babel Error—are you on Windows by any chance? The version of Open Babel bundled with ChemmineOB is not able to generate InChI (girke-lab/ChemmineOB#37 (comment)https://github.com/girke-lab/ChemmineOB/issues/37#issuecomment-2008364855), but this shouldn't be an issue for volcalc as it does not use InChI. Unfortunately there isn't a way to silence these Open Babel errors about InChI generation and you'll just have to ignore them.

I would like to know how to silence this. Happy to schedule a Zoom call if that helps.

  1. I'm assuming the curl error happened when running get_mol_kegg(), is that correct? Do you get this error consistently? It could be that the KEGG API was down temporarily when you ran this, or that your internet connection was interrupted during download. If this persists, let me know and I can look into it.

Yes, this error persists if I only run volcalc code on this page- https://meredith-lab.github.io/volcalc/ I have been using the R version and all updated packages- here is the info

R version 4.3.3 (2024-02-29 ucrt) -- "Angel Food Cake" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit)

I have changed the out_path to the directory I want the KEGG to follow. The attached .rmd file will have info.

Hopefully, this helps resolve the issue. I am looking forward to using it for our data.

Vaish

(Vaishnavi Padaki (She/her/hers)) Ph.D. Candidate Nash 352/356 Department of Microbiologyhttps://microbiology.oregonstate.edu/ Oregon State University Ph. 541 7375079

Art integration Intern Patricia Valian Reser Center for the Creative Arts (PRAx)https://liberalarts.oregonstate.edu/prax Oregon State University Nash 356


From: Eric R. Scott @.> Sent: Friday, March 22, 2024 10:52 AM To: Meredith-Lab/volcalc @.> Cc: Padaki, Vaishnavi Guruprasad @.>; Author @.> Subject: Re: [Meredith-Lab/volcalc] ChemmineR error not allowing calc_vol() to function (Issue #105)

You don't often get email from @.*** Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification

[This email originated from outside of OSU. Use caution with links and attachments.]

The curl error could also have come up because of downloading to a temporary directory. If you change the out_path in the example you might have better luck. E.g.

files <- get_mol_kegg(c("C16181", "C00042"), dir ="path/to/download/folder")

— Reply to this email directly, view it on GitHubhttps://github.com/Meredith-Lab/volcalc/issues/105#issuecomment-2015620480, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A3GZAMHW2R7DKQS2765YYOTYZRVVRAVCNFSM6AAAAABFCK6SR2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJVGYZDANBYGA. You are receiving this because you authored the thread.Message ID: @.***>

Aariq commented 5 months ago

I don't think your attachment made it through to the GitHub issue, but you could include a minimal reproducible example (AKA a reprex) and that would help to diagnose your problem.

Unfortunately, there is no way in R to silence the Open Babel messages, errors, and warnings produced by ChemmineOB, a dependency of volcalc (see notes/discussion in #85 and #56).

VaishChar commented 5 months ago

Volcalc_03222024.pdf I have uploaded a .pdf file that was created using R. While using the Reprex package, I found it quite complicated to utilize. In the third chunk of the code, I have hashtagged it since it gave errors. In the same chunk, where I mentioned the paths for the R code, I copy-pasted the code from Github and created functions. However, the last two lines for the functions "get_mol_kegg" and "vol_calc" didn't run and gave an "atom2tibble of ChemmineR" error. I appreciate your help.

Aariq commented 5 months ago

volcalc is an R package that needs to be installed rather than sourcing .R files in this repository. Try this:

install.packages("volcalc", repos = c("https://cct-datascience.r-universe.dev", getOption("repos")))
library(volcalc)
out_path <- "./output"
files <- get_mol_kegg(compound_ids = "C16181", dir = out_path)
calc_vol(files$mol_path)

You can generate a reprex by copying these lines to the clipboard (without the install.packages() command) and then running reprex::reprex() and then pasting into GitHub like so:

library(volcalc)
out_path <- "./output"
files <- get_mol_kegg(compound_ids = "C16181", dir = out_path)
calc_vol(files$mol_path)
#> # A tibble: 1 × 5
#>   mol_path            formula  name                                 rvi category
#>   <chr>               <chr>    <chr>                              <dbl> <fct>   
#> 1 ./output/C16181.mol C6H7Cl5O beta-2,3,4,5,6-Pentachlorocyclohe…  6.98 high

Created on 2024-03-22 with reprex v2.1.0

VaishChar commented 5 months ago

I am still receiving the same error-

Here is my new code-

Proj.path is set in the beginning of the project (chunk 1)

Set working directory (where files will be loaded from and saved to) (I change the file path as per every sample)

proj.path.1 <- setwd("C:/Users/padakiv/Documents/PhD/Chapter 2 data/Dielrun_PTRViewer"); getwd()

> [1] "C:/Users/padakiv/Documents/PhD/Chapter 2 data/Dielrun_PTRViewer"

print(getwd())

> [1] "C:/Users/padakiv/Documents/PhD/Chapter 2 data/Dielrun_PTRViewer"

Saves path where data files are stored

data.path <- paste0(proj.path.1, "/PTR_viewer_combined_data") print (data.path)

> [1] "C:/Users/padakiv/AppData/Local/Temp/RtmpiGDUrj/reprex-677c439e505a-mid-pig/PTR_viewer_combined_data"

Saves path where output files will be saved

output.path.1 <- paste0(proj.path.1, "/output") print (output.path.1)

> [1] "C:/Users/padakiv/AppData/Local/Temp/RtmpiGDUrj/reprex-677c439e505a-mid-pig/output"

Set seed

user.seed <- 999 # seed for replication, number is arbitrary set.seed(user.seed)

install.packages("volcalc", repos = c("https://cct-datascience.r-universe.dev", getOption("repos")))

> Installing package into 'C:/Users/padakiv/AppData/Local/R/win-library/4.3'

> (as 'lib' is unspecified)

> package 'volcalc' successfully unpacked and MD5 sums checked

>

> The downloaded binary packages are in

> C:\Users\padakiv\AppData\Local\Temp\Rtmp46aAIy\downloaded_packages

library(volcalc) out_path <- output.path.1 files <- get_mol_kegg(compound_ids = "C16181", dir = out_path) calc_vol(files$mol_path)

> # A tibble: 1 × 5

> mol_path formula name rvi category

>

> 1 C:/Users/padakiv/AppData/Local/Temp/RtmpiGDUrj/r… C6H7Cl… beta… 6.98 high

Created on 2024-03-22 with reprex v2.1.0https://reprex.tidyverse.org/

Here are code lines from the previous code which I had copied from repository-

groups <- groups %>% dplyr::mutate(dplyr::across(dplyr::everything(), as.integer))

> Error in groups %>% dplyr::mutate(dplyr::across(dplyr::everything(), as.integer)): could not find function "%>%"

rings <- data.frame(t(ChemmineR::rings(compound_sdf, type = "count", arom = TRUE, inner = TRUE)))

> Error in eval(expr, envir, enclos): object 'compound_sdf' not found

atoms <- atomcount2tibble(ChemmineR::atomcount(compound_sdf))

> Error in atomcount2tibble(ChemmineR::atomcount(compound_sdf)): could not find function "atomcount2tibble"

carbon_bond_data <- data.frame(ChemmineR::conMA(compoundsdf)[[1]]) %>% dplyr::select(dplyr::contains("C")) %>% tibble::rownames_to_column() %>% dplyr::filter(stringr::strdetect(rowname, "C")) %>% tibble::column_to_rownames(var = "rowname")

> Error in data.frame(ChemmineR::conMA(compoundsdf)[[1]]) %>% dplyr::select(dplyr::contains("C")) %>% : could not find function "%>%"

if (nrow(carbon_bond_data) == 0){ carbon_dbl_count <- tibble::tibble(n = 0) } else { carbon_dbl_count <- data.frame(all = unlist(carbon_bond_data)) %>% dplyr::count(all) %>% dplyr::filter(all == 2) %>% dplyr::select(n) %>% dplyr::mutate(n = n / 2) }

> Error in eval(expr, envir, enclos): object 'carbon_bond_data' not found

if (nrow(carbon_dbl_count) == 0) { carbon_dbl_count <- tibble::add_row(carbon_dbl_count, n = 0) }

> Error in eval(expr, envir, enclos): object 'carbon_dbl_count' not found

Created on 2024-03-22 with reprex v2.1.0https://reprex.tidyverse.org/

Thank you!

Vaish

(Vaishnavi Padaki (She/her/hers)) Ph.D. Candidate Nash 352/356 Department of Microbiologyhttps://microbiology.oregonstate.edu/ Oregon State University Ph. 541 7375079

Art integration Intern Patricia Valian Reser Center for the Creative Arts (PRAx)https://liberalarts.oregonstate.edu/prax Oregon State University Nash 356


From: Eric R. Scott @.> Sent: Friday, March 22, 2024 2:39 PM To: Meredith-Lab/volcalc @.> Cc: Padaki, Vaishnavi Guruprasad @.>; Author @.> Subject: Re: [Meredith-Lab/volcalc] calc_vol() errors with 'could not find function attomcount2tibble' (Issue #105)

You don't often get email from @.*** Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification

[This email originated from outside of OSU. Use caution with links and attachments.]

volcalc is an R package that needs to be installed rather than sourcing .R files in this repository. Try this:

install.packages("volcalc", repos = c("https://cct-datascience.r-universe.dev", getOption("repos"))) library(volcalc) out_path <- "./output" files <- get_mol_kegg(compound_ids = "C16181", dir = out_path) calc_vol(files$mol_path)

You can generate a reprex by copying these lines to the clipboard (without the install.packages() command) and then running reprex::reprex() and then pasting into GitHub like so:

library(volcalc) out_path <- "./output" files <- get_mol_kegg(compound_ids = "C16181", dir = out_path) calc_vol(files$mol_path)

> # A tibble: 1 × 5

> mol_path formula name rvi category

>

> 1 ./output/C16181.mol C6H7Cl5O beta-2,3,4,5,6-Pentachlorocyclohe… 6.98 high

Created on 2024-03-22 with reprex v2.1.0https://reprex.tidyverse.org/

— Reply to this email directly, view it on GitHubhttps://github.com/Meredith-Lab/volcalc/issues/105#issuecomment-2015967034, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A3GZAMEVKHXQCIGHUZAW5B3YZSQIXAVCNFSM6AAAAABFCK6SR2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJVHE3DOMBTGQ. You are receiving this because you authored the thread.Message ID: @.***>

Aariq commented 5 months ago

Your reprex shows no errors and returns the correct results for that compound.

library(volcalc)
out_path <- output.path.1
files <- get_mol_kegg(compound_ids = "C16181", dir = out_path)
calc_vol(files$mol_path)
#> # A tibble: 1 × 5
#>   mol_path                                          formula name    rvi category
#>   <chr>                                             <chr>   <chr> <dbl> <fct>
#> 1 C:/Users/padakiv/AppData/Local/Temp/RtmpiGDUrj/r… C6H7Cl… beta…  6.98 high

I wouldn't expect any of the code copied from the .R files in this repository to work, so I am not surprised by those errors. The code in this repository is not meant to be run by users in this way, it is part of an R package. The volcalc package needs to be installed to work correctly, just like any other R package. There's some good information about installing and loading R packages here: https://moderndive.netlify.app/1-getting-started#packages

You might also find it helpful to take a look at the "Getting Started" page for volcalc here: https://meredith-lab.github.io/volcalc/articles/volcalc.html.

VaishChar commented 5 months ago

Thank you for your suggestions. I had to uninstall and re-install the R for the code to work.

Vaish

(Vaishnavi Padaki (She/her/hers)) Ph.D. Candidate Nash 352/356 Department of Microbiologyhttps://microbiology.oregonstate.edu/ Oregon State University Ph. 541 7375079

Art integration Intern Patricia Valian Reser Center for the Creative Arts (PRAx)https://liberalarts.oregonstate.edu/prax Oregon State University Nash 356


From: Eric R. Scott @.> Sent: Friday, March 22, 2024 3:17 PM To: Meredith-Lab/volcalc @.> Cc: Padaki, Vaishnavi Guruprasad @.>; Author @.> Subject: Re: [Meredith-Lab/volcalc] calc_vol() errors with 'could not find function attomcount2tibble' (Issue #105)

You don't often get email from @.*** Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification

[This email originated from outside of OSU. Use caution with links and attachments.]

Your reprex shows no errors and returns the correct results for that compound.

library(volcalc) out_path <- output.path.1 files <- get_mol_kegg(compound_ids = "C16181", dir = out_path) calc_vol(files$mol_path)

> # A tibble: 1 × 5

> mol_path formula name rvi category

>

> 1 C:/Users/padakiv/AppData/Local/Temp/RtmpiGDUrj/r… C6H7Cl… beta… 6.98 high

I wouldn't expect any of the code copied from the .R files in this repository to work, so I am not surprised by those errors. The code in this repository is not meant to be run by users in this way, it is part of an R package. The volcalc package needs to be installed to work correctly, just like any other R package. There's some good information about installing and loading R packages here: https://moderndive.netlify.app/1-getting-started#packages

You might also find it helpful to take a look at the "Getting Started" page for volcalc here: https://meredith-lab.github.io/volcalc/articles/volcalc.html.

— Reply to this email directly, view it on GitHubhttps://github.com/Meredith-Lab/volcalc/issues/105#issuecomment-2016012128, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A3GZAMEXKXSB4AL3O4LX233YZSUW7AVCNFSM6AAAAABFCK6SR2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJWGAYTEMJSHA. You are receiving this because you authored the thread.Message ID: @.***>

Aariq commented 5 months ago

Great! Glad you got it working. Let us know if you have other questions or run into other issues.