# create res, a list to hold pseudobulk DE results for all contrasts
for (i in names(contrast)) {
cat("Contrast: ", i,"\n")
res <- pbDS(pb,
design = mm,
contrast = contrast[[i]],
verbose = TRUE,
BPPARAM = BiocParallel::MulticoreParam(6))
results_list[[i]] <- res
}
# extract contrast
contrast_vtp_DMSO <- res$table$`VTP-DMSO`
# renaming columns
for (cell in names(contrast_vtp_DMSO)) {
contrast_vtp_DMSO[[cell]] <-
contrast_vtp_DMSO[[cell]] |>
dplyr::rename(log2FoldChange = logFC,
pvalue = p_val,
padj = p_adj.loc)
rownames(contrast_vtp_DMSO[[cell]]) <- contrast_vtp_DMSO[[cell]]$gene
}
# optional: update de + enrich list names
new_names <- c(
"NK1 A+B" = "NK1_A_B",
"NK1 C" = "NK1_C",
"NK2" = "NK2",
"NK3" = "NK3" ,
"NKint" = "NKint"
)
names(contrast_vtp_DMSO) <- new_names[names(contrast_vtp_DMSO)]
names(func_res) <- new_names[names(func_res)]
# create dde object
dde <- DeeDeeExperiment(sce_NKcells, # sce object
de_results = contrast_vtp_DMSO, # DEA results
enrich_results = func_res # FEA results
)