Skip to content
Show file tree
Hide file tree
Showing 58 changed files with 433 additions and 345 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
URL: https://smorabit.github.io/hdWGCNA/
Imports: WGCNA, Seurat, Matrix, harmony, igraph, ggplot2, dplyr, tester, UCell, proxy
Imports: WGCNA, Seurat, Matrix, harmony, igraph, ggplot2, dplyr, tester, proxy
Suggests: testthat (>= 3.0.0)
Config/testthat/edition: 3
Depends:
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export(AvgModuleExpr)
export(BinPseudotime)
export(CheckSeurat5)
export(CheckWGCNAName)
export(ConstructMetacells)
export(ConstructMetaspots)
Expand Down Expand Up @@ -114,11 +115,14 @@ export(shuffle_points)
export(umap_theme)
import(Matrix)
import(Seurat)
import(SeuratObject)
import(WGCNA)
import(ggplot2)
import(harmony)
import(igraph)
import(magrittr)
import(patchwork)
import(proxy)
import(uwot)
importFrom(Matrix,colSums)
importFrom(Matrix,rowSums)
Expand Down
22 changes: 14 additions & 8 deletions R/Pseudobulk.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#' @param replicate_col column in seurat_obj@meta.data denoting each replicate / sample
#' @param label_col column in seurat_obj@meta.data denoting an additional label of interest, for example disease status or biological sex. This is not a required argument and is typically only used for consensus WGCNA
#' @param assay Assay in seurat_obj containing isoform expression information.
#' @param slot Slot in seurat_obj, default to counts slot and we generally recommend using counts here.
#' @param slot Slot to extract data for aggregation. Default = 'counts'
#' @param layer Layer to extract data for aggregation. Default = 'counts'. Layer is used with Seurat v5 instead of slot.
#' @param min_reps The minimum number of different biological replicates allowed. Error will be thrown if the number of reps is too low.
#' @param wgcna_name The name of the hdWGCNA experiment in the seurat_obj@misc slot
#' @details
Expand All @@ -33,15 +34,16 @@ ConstructPseudobulk <- function(
label_col = NULL,
assay = 'RNA',
slot = 'counts',
layer = 'counts',
min_reps = 20,
wgcna_name = NULL
){

# get data from active assay if wgcna_name is not given
if(is.null(wgcna_name)){wgcna_name <- seurat_obj@misc$active_wgcna}
if(!CheckWGCNAName(seurat_obj, wgcna_name)){
stop(paste0("Invalid wgcna_name supplied: ", wgcna_name))
}
# get data from active assay if wgcna_name is not given
if(is.null(wgcna_name)){wgcna_name <- seurat_obj@misc$active_wgcna}
if(!CheckWGCNAName(seurat_obj, wgcna_name)){
stop(paste0("Invalid wgcna_name supplied: ", wgcna_name))
}

# check that selected assay is in the seurat object
if(!(assay %in% Assays(seurat_obj))){
Expand Down Expand Up @@ -92,8 +94,12 @@ ConstructPseudobulk <- function(
# get the WGCNA genes:
genes_use <- GetWGCNAGenes(seurat_obj, wgcna_name)

# get counts matrix
X <- Seurat::GetAssayData(seurat_obj, assay=assay, slot=slot)
# get expression matrix:
if(CheckSeurat5()){
X <- SeuratObject::LayerData(cur_seurat, assay=assay, layer=layer)
} else{
X <- Seurat::GetAssayData(cur_seurat, assay=assay, slot=slot)
}

# get pseudobulk replicates
pseudobulk_list <- to_pseudobulk(
Expand Down
3 changes: 1 addition & 2 deletions docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ articles:
pseudobulk: pseudobulk.html
pseudotime: pseudotime.html
sctransform: sctransform.html
tf_net: tf_net.html
last_built: 2024-02-28T05:33Z
last_built: 2024-02-28T06:02Z
urls:
reference: https://smorabit.github.io/hdWGCNA/reference
article: https://smorabit.github.io/hdWGCNA/articles
Expand Down
151 changes: 151 additions & 0 deletions docs/reference/CheckSeurat5.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4bacda8

Please sign in to comment.