joey711 / phyloseq

phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
http://joey711.github.io/phyloseq/
584 stars 187 forks source link

could not find function "cca.phyloseq" #1460

Open slambrechts opened 3 years ago

slambrechts commented 3 years ago

Hi,

When running

cca.phyloseq(physeq_CSS, formula = physeq_CSS ~ Bedrock + dem + pH_dest + TOC + N.NH4 + N_NO3 + P_PO4 + TN_perc + TP_perc + conductivity, method = "RDA")

I get:

could not find function "cca.phyloseq"

I could however find the function in the help pages. Any idea what is causing this?

ycl6 commented 3 years ago

@slambrechts

Based on the information provided in NEWS, the function was removed since v0.99.44

https://github.com/joey711/phyloseq/blob/dc35470498c79284231d41d1add1a74940f51fb7/inst/NEWS#L1359-L1361

However, you can change the method= argument in the ordinate function to perform ordination with CCA, for example:

library(phyloseq)
data(GlobalPatterns)

# prune OTUs that are not present in at least one sample
GP = prune_taxa(taxa_sums(GlobalPatterns) > 0, GlobalPatterns)

# Use ordinate to call vegan::cca()
cca1 <- ordinate(GP, method = "CCA", formula = ~ SampleType)

# Use vegan::cca() directly
cca2 <- vegan::cca(t(otu_table(GP)) ~ SampleType, data = data.frame(sample_data(GP)))

Both will give you the same results:

              Inertia Proportion Rank
Total         11.4664     1.0000     
Constrained    6.8297     0.5956    8
Unconstrained  4.6367     0.4044   17
Inertia is scaled Chi-square 

Eigenvalues for constrained axes:
  CCA1   CCA2   CCA3   CCA4   CCA5   CCA6   CCA7   CCA8 
0.9800 0.9369 0.9226 0.8937 0.8568 0.8411 0.7659 0.6326 

Eigenvalues for unconstrained axes:
   CA1    CA2    CA3    CA4    CA5    CA6    CA7    CA8 
0.6062 0.6026 0.5856 0.5028 0.4971 0.3626 0.3551 0.2524 
(Showing 8 of 17 unconstrained eigenvalues)
pauGuas commented 2 years ago

@ycl6 Can you use this code with multiple predictors?

ycl6 commented 2 years ago

@pauGuas You can have more than one predictors in the model formula, but obviously the analysis will become more complex and less likely to detect strong relationships the more you include. You can read the cca manual here, and future question on vegan's features is more appropriate in its GitHub page.