ChiLiubio / microeco

An R package for data analysis in microbial community ecology
GNU General Public License v3.0
181 stars 55 forks source link

Correlation of an ASV with various environmental variables #372

Open guianrey opened 4 weeks ago

guianrey commented 4 weeks ago

Hi Chi, I have a pretty basic query, I need to do a corelation of a special ASV and several environmental variables, I guess I could try it with the following script t1$cal_cor(use_data = “meco_dataset”, p_adjust_method = “fdr”) t1$plot_cor() but I just need to plot an ASV correlated with my environmental variables.

Could you please help me?

Best regards

Guillermo

ChiLiubio commented 4 weeks ago

Hi Guillermo, There are two ways to perform correlation between variables and ASV abundance. The first one is to make ASV a taxonomic level and perform following analysis like Genus level.

library(microeco)
data(dataset)
data(env_data_16S)
dataset$add_rownames2taxonomy(use_name = "ASV")
dataset$cal_abund()
t1 <- trans_env$new(dataset = dataset, add_data = env_data_16S[, 4:11])
t1$cal_cor(use_data = "ASV")

Another is to provide ASV data as others. Something like the pseudo code.

library(microeco)
data(dataset)
data(env_data_16S)
t1 <- trans_env$new(dataset = dataset, add_data = env_data_16S[, 4:11])
some_ASV_data <- a_dataframe "should be a data.frame, rows are samples, columns are ASV"
t1$cal_cor(use_data = "other", add_abund_table = some_ASV_data)

Best, Chi