<jupyter_start><jupyter_text>This notebook is to perform Adonis test on continuous variables for beta diversities (Aitchison)<jupyter_code>library(vegan)
dat <- read.delim("mapping_sleep_alpha.txt")
head(dat)
distance <- read.table(file = 'distance-matrix/distance-matrix.tsv', sep = '\t', header = TRUE, row.names = 1)
distance <- distance[ , order(colnames(distance))]
distance <- distance[ order(rownames(distance)), ]
distance[] <- lapply(distance, as.numeric)
head(distance)
#select test variables
varname <- c("X.SampleID", "Age", "AMAMPT", "AMPHIT", "AMFVT", "PQPSQI", "BMI", "Height", "Weight", "PASCORE", "SLSLPHRS", "PQPEFFCY")
meta <- dat[c(varname)]
head(meta)
lapply(meta, class)
set.seed(123)
meta$Age<- as.numeric(as.character(meta$Age))
age <- adonis(distance~Age, data = meta)
age
set.seed(123)
BMI<- adonis(distance~BMI, data = meta)
BMI
set.seed(123)
PASCORE<- adonis(distance~PASCORE, data = meta)
PASCORE
set.seed(123)
meta$AMAMPT <- as.numeric(as.character(meta$AMAMPT))
ind <- which(is.na(meta$AMAMPT))
dist <- distance[-ind, ]
dist <- dist[, -ind]
meta.omit <- meta[!is.na(meta$AMAMPT), ]
AMAMPT<- adonis(dist~AMAMPT, data = meta.omit)
AMAMPT
set.seed(123)
meta$SLSLPHRS <- as.numeric(as.character(meta$SLSLPHRS))
ind <- which(is.na(meta$SLSLPHRS))
dist <- distance[-ind, ]
dist <- dist[, -ind]
meta.omit <- meta[!is.na(meta$SLSLPHRS), ]
SLSLPHRS  <- adonis(dist~SLSLPHRS, data = meta.omit)
SLSLPHRS
set.seed(123)
meta$AMPHIT <- as.numeric(as.character(meta$AMPHIT))
ind <- which(is.na(meta$AMPHIT))
dist <- distance[-ind, ]
dist <- dist[, -ind]
meta.omit <- meta[!is.na(meta$AMPHIT), ]
acrophase  <- adonis(dist~AMPHIT, data = meta.omit)
acrophase
set.seed(123)
meta$AMFVT <- as.numeric(as.character(meta$AMFVT))
ind <- which(is.na(meta$AMFVT))
dist <- distance[-ind, ]
dist <- dist[, -ind]
meta.omit <- meta[!is.na(meta$AMFVT), ]
AMFVT  <- adonis(dist~AMFVT, data = meta.omit)
AMFVT
set.seed(123)
PQPSQI<- adonis(distance~PQPSQI, data = meta)
PQPSQI
set.seed(123)
meta$PQPEFFCY <- as.numeric(as.character(meta$PQPEFFCY))
ind <- which(is.na(meta$PQPEFFCY))
dist <- distance[-ind, ]
dist <- dist[, -ind]
meta.omit <- meta[!is.na(meta$PQPEFFCY), ]
PQPEFFCY  <- adonis(dist~PQPEFFCY, data = meta.omit)
PQPEFFCY<jupyter_output>Warning message in eval(expr, envir, enclos):
“NAs introduced by coercion”<jupyter_text>adjust p value by BH method<jupyter_code>name <- c(  "Age", "BMI", "PASCORE", "AMAMPT", "SLSLPHRS", "AMPHIT", "AMFVT", "PQPSQI", "PQPEFFCY",
          'GIERACE', 'SITE', 'GIMSTAT', 'MHDIAB', 'MHRHEU1', 'MHOA', 'MHCHF', 'MHMI', 'MHDEPR', 
          'TUDRAMT_REVISED', 'PQPSLMED', 'PQPSQUAL', 'QLCOMP', 'SLEEPHRS', 'PQBADSLP', 'TURSMOKE', 
          'M1ADEPR', 'M1BENZO', 'PQPEFFIC', 'AMAMPT_C1', 'AMFVT_C1', 'AMPHIT_15SD')

pval <- c(0.09,0.035,0.001,0.482,0.411,0.628,0.001,0.01,0.018,
          0.001,0.006,0.1,0.001,0.562,0.038,0.829,0.886,0.031, 0.16,0.587,0.104,0.467,
          0.251,0.012,0.312,0.002,0.648,0.116,0.335, 0.004,0.137)
d <- cbind(name, pval)
d <-data.frame(name, pval, stringsAsFactors = F)
d <- d[-which(d$name %in% c('AMAMPT_C1', 'AMFVT_C1', 'AMPHIT_15SD','MHOA', 'MHCHF', 'MHMI','PQPSQUAL', 'QLCOMP')),]
d <- cbind(d, round(p.adjust(d$pval, "BH"), 4))
colnames(d)[3] <- "qval"
d<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20875420875420875, 'fraction_numerical': 0.04897459442913989, 'mean_word_length': 5.321083172147002, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '195531', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1413, 'n_words': 245, 'path': '3.3 Beta Diversity(Aitchison) -- Continuous (R).ipynb', 'repo_name': 'knightlab-analyses/mros_sleep_analysis', 'size': '3267'}