Hello! I have a general question about the MEs that I obtain from pseudobulked hdWGCNA. I followed the vignette and GetMEs yields cell-level ME values rather than donor level values. My psuedobulks are donor_cluster and that is the level for which I want to see MEs and use this for downstream Module-Trait correlations. Ideally, I want one measure per module for each donor to carry into analysis. Should my hdWGCNA input be at an aggregated level prior to using the tool, because currently I am using the package to achieve aggregation. I attempted to calculate donor-level MEs using the function below but I am curious if there is an easier/better way to obtain a value for each module by donor rather than cell-level.
get_pseudobulk_MEs <- function(seu_obj, prefix) {
- datExpr <- GetDatExpr(seu_obj)
- datExpr <- as.data.frame(datExpr)
- mods <- GetModules(seu_obj)
- mods <- mods[mods$module != "grey", , drop = FALSE]
- gene_col <- if ("gene_name" %in% colnames(mods)) "gene_name" else "gene"
- gene2mod <- setNames(as.character(mods$module), as.character(mods[[gene_col]]))
- common_genes <- intersect(colnames(datExpr), names(gene2mod))
- datExpr_use <- datExpr[, common_genes, drop = FALSE]
- mod_colors <- gene2mod[common_genes]
- me_list <- WGCNA::moduleEigengenes(
-
expr = as.matrix(datExpr_use),
-
- )
- me_df <- as.data.frame(me_list$eigengenes)
- rownames(me_df) <- rownames(datExpr_use)
- colnames(me_df) <- sub("^ME", "", colnames(me_df))
- colnames(me_df) <- paste0(prefix, "_", colnames(me_df))
- me_df$pb_id <- rownames(me_df)
- me_df$Participant_ID <- sub("\..*$", "", me_df$pb_id)
- me_df
Hello! I have a general question about the MEs that I obtain from pseudobulked hdWGCNA. I followed the vignette and GetMEs yields cell-level ME values rather than donor level values. My psuedobulks are donor_cluster and that is the level for which I want to see MEs and use this for downstream Module-Trait correlations. Ideally, I want one measure per module for each donor to carry into analysis. Should my hdWGCNA input be at an aggregated level prior to using the tool, because currently I am using the package to achieve aggregation. I attempted to calculate donor-level MEs using the function below but I am curious if there is an easier/better way to obtain a value for each module by donor rather than cell-level.