library(“ggplot2”) library(“gridExtra”) library(“edgeR”) library(“UpSetR”) library(“sva”)
sva::ComBat_seq
dir <- “~/Desktop/Feature-Counts/Unadjusted/”
counts <-read.csv(paste0(dir, “counts-prunved-v1-no3months.csv”), sep=“,”, stringsAsFactors = F, header = T)
counts_matrix <- as.matrix(counts)
batch_list <- c(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5)
cov1_age <- c(9, 9, 9, 9, 12, 12, 12, 12, 12, 12, 15, 15, 15, 15, 15, 15, 18, 18, 18, 6, 6, 6, 6, 6, 6, 15, 15, 15, 15, 15, 15, 12, 12, 18, 18, 18, 18, 18, 18, 18, 18, 21, 21, 21, 21, 21, 9, 9, 6, 9, 24, 6, 9, 12, 21, 24, 6, 9, 12, 21, 24, 6, 12, 21, 9, 12, 21, 6, 9, 21, 9, 12, 21, 6, 18, 18, 9)
cov2_Sex <- c(2, 3, 3, 3, 2, 2, 2, 3, 3, 3, 2, 2, 2, 3, 3, 3, 2, 2, 2, 2, 2, 2, 3, 3, 3, 2, 2, 2, 3, 3, 3, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 3, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 3, 3, 3, 2, 3, 2, 3, 2, 2, 2, 3, 2, 3, 3, 3, 2)
Cov3_Strain <- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0)
covar_mat <- cbind(cov1_age, cov2_Sex, Cov3_Strain)
head(counts_matrix)
dim(counts_matrix)
counts_no_names <- counts[,2:78]
count_matrix_mine <- as.matrix(counts_no_names)
adjusted_counts <- ComBat_seq(count_matrix_mine, batch=batch_list, group=NULL, covar_mod=covar_mat)
write.csv(as.data.frame(adjusted_counts), file = paste0(dir,“Adjusted-Counts-pruned-V1-Sex-Edit-no3months.csv”), quote = FALSE, row.names = T, col.names = T, sep = “,”)