darcyj / specificity

R package for calculating specificity in ecological data
7 stars 1 forks source link

run specificity in R-windows #6

Open jamorillo opened 1 year ago

jamorillo commented 1 year ago

Hello! I have been testing out the package and it is fantastic, but I've run into a problem when I try to use the host phylogeny. It appears that it's not compatible with the R installation on Windows, even setting n_cores=1. Is there a simple solution for this? Thank you!

Here's the error message I've been getting:

specs_list$"Host Phylogeny" <- phy_or_env_spec_windows(otutable, hosts=metadata$Species_otl_ID_test, hosts_phylo=tree, n_sim=500, n_cores=1, seed = 1975) Checking inputs... ...Converting tree to dist... Error in parallel::mclapply(X = phy$edge[, 2], FUN = .get_node_tip_range, : 'mc.cores' > 1 is not supported on Windows In addition: Warning message: In make_nested_set(tree) : Windows is incompatible with n_cores > 1.

darcyj commented 1 year ago

Hello,

I've looked over the code and I can't find an obvious issue. The code has a built-in checker to give a warning on windows first, and it didn't go off (because you set n_cores to 1). Here are a few options, I hope one of them resolves the issue for you:

a. set n_cores to 0. the code only checks if its > 1, so it will probably work.

b. run tree2mat() separately on your tree, to make a matrix object. Then feed it into phy_or_env_spec() instead of the tree as the env argument (see documentation).

c. if that didn't work, use the ape package's cophenetic.phylo() function to make a distance matrix instead. it won't work if your data set is too large, though, and it's slow.

Sorry you're having this issue; I wish I had a windows box to troubleshoot but i'm all mac and linux :(

darcyj commented 1 year ago

Update: I figured it out and I think the issue should be fixed now. Please re-install specificity and let me know if that fixes it for you. Thanks for testing!

jamorillo commented 1 year ago

Hello! OK, now the issue of the numbers of cores is gone! Thanks a lot!! I am experiencing other issues, but I believe they are related to my data. I will try to resolve them. P.S.: I'm also a Linux fan, at least for bioinformatics ;)

jamorillo commented 1 year ago

Apologies, just one additional question. In the dataset I'm working with, I have ONE sample of fungi per host species (it also involves ITS data in plant roots like some of your papers). The design included 150 "composite" samples, one per plant species (I know it would have been ideal to sequence all). Can I use the phylogenetic tree with phy_or_env_spec with only one sample/species? Just to rule out if this is an issue. Thank you so much!

darcyj commented 1 year ago

I’m not sure what you mean by one sample per plant species - just one fungus per plant, or do you have many fungi per plant? In the second case, it will work. Also not sure what you mean by composite samples.