Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
02ea704
correct CN helper to use correct NSCL_multi file
phoman14 Oct 22, 2025
aa159b4
CN Copy Global code from NIDAP
phoman14 Oct 22, 2025
c26427e
FQC copy from BRACA_Support 250812
phoman14 Oct 22, 2025
a9236c1
coppy from NIDAP seed for SCDblFinder
phoman14 Oct 22, 2025
45272f1
FilterQC test functions
phoman14 Oct 22, 2025
a536fc5
PRD copy from BRACA_Support 250812
phoman14 Oct 22, 2025
65441d4
Copy Global code from NIDAP
phoman14 Oct 22, 2025
8d64ce3
PRD test scripts
phoman14 Oct 22, 2025
3e13ce7
test update if file does not extest
phoman14 Oct 22, 2025
4306260
Copy Harmony from NIDAP
phoman14 Oct 22, 2025
f7b8fc9
ModScore different copy from NIDAP
phoman14 Oct 22, 2025
b348803
ColByMarkerTable different copy from NIDAP
phoman14 Oct 22, 2025
9535066
NameCluster different copy from NIDAP
phoman14 Oct 22, 2025
f5c8b7e
DotPltMeta different copy from NIDAP
phoman14 Oct 22, 2025
4a232f9
VlnPlt Different function names Nidap vs Pkg so added Nidp to bottom
phoman14 Oct 22, 2025
a86e5f6
FilterSObyMeta small different copy from NIDAP
phoman14 Oct 22, 2025
10d142b
FindMarkers copy from NIDAP
phoman14 Oct 22, 2025
e8fee36
DL copy from BRACA_Support 250812
phoman14 Oct 22, 2025
46b0019
Merge branch 'DEV' of https://github.com/NIDAP-Community/SCWorkflow i…
phoman14 Oct 22, 2025
cb968a1
DL coppy from NIDAP very different using NIDAP copy will not bring ov…
phoman14 Oct 22, 2025
3ede163
Changes to pass tests
phoman14 Oct 22, 2025
bc98027
MS modifications for UNIT tests
phoman14 Oct 23, 2025
545ee3a
Changes made to make various unit tests to pass
phoman14 Oct 23, 2025
4d061cf
Update test scripts for noGlobal Code functions
phoman14 Oct 23, 2025
580e930
manually Add Vignette info from GalaxyCLI
phoman14 Oct 23, 2025
db487d6
Overview Vignette make option to run chunks
phoman14 Oct 23, 2025
8b323e4
Running Overview and Anno Markdown
phoman14 Oct 23, 2025
7f8a315
create vignette from pkgdown::build_site()
phoman14 Oct 28, 2025
58ba917
cleanup .gitignore
phoman14 Nov 24, 2025
aae3593
clean up gitignore local
phoman14 Nov 24, 2025
90f2780
Merge branch 'DEV' of https://github.com/NIDAP-Community/SCWorkflow i…
phoman14 Nov 24, 2025
7710ebf
Complete Vignetts RMD for all sections
phoman14 Nov 24, 2025
6f7c18a
errors in Vignette output
phoman14 Nov 25, 2025
ee27247
Make uniform output list object,data,plots
phoman14 Nov 25, 2025
e017096
update vignetts for standard output"
phoman14 Nov 25, 2025
c99e5cd
add Contributing Rmd to Vignette
phoman14 Nov 25, 2025
096c836
NIDAP json files for all templates
phoman14 Nov 25, 2025
061898f
remove extra json files
phoman14 Dec 15, 2025
f56f5e6
add Rshape2:: to melt
phoman14 Dec 15, 2025
b5bc6c6
docs: create flow chart for new features and match with documentation
phoman14 Dec 16, 2025
4be953b
update unit tests, fix ROxygen format
bianjh-cloud Jan 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
512 changes: 512 additions & 0 deletions .Rhistory

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions .gitignore
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# For SCWorkflow dev
.DS_Store
.nfs*
*.png
#*.png
Rcheck.txt
*.pdf
#*.pdf
tests/testthat/otherData/
tests/testthat/_snaps
tests/testthat/fixtures/
tests/testthat/output/

.Rproj.user
*.txt

inst/doc
#inst/extdata/*
docs
*.Rds
*.rds
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: SCWorkflow
Title: SCWorkflow from NIDAP
Version: 1.0.2
Authors@R: c(person("Maggie", "Cam", email = "maggie.cam@nih.gov", role = "aut", comment = c(ORCID = "0000-0001-8190-9766")),
Authors@R: c(person("Maggie", "Cam", email = "maggie.cam@nih.gov", role = "aut", comment = c(ORCID = "0000-0001-8190-9766")),
person("Thomas", "Meyer", email = "thomas.meyer@nih.gov", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-7185-5597")),
person("Jing", "Bian", email = "bianjh@nih.gov", role = "aut", comment = c(ORCID = "0000-0001-7109-716X")),
person("Alexandra", "Michalowski", email = "michaloa@mail.nih.gov", role = "aut", comment = c(ORCID = "0000-0001-9259-6101")),
Expand All @@ -18,7 +18,7 @@ Description: A set of functions for analyzing single-cell RNA-seq data using the
License: MIT
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.3
Suggests:
testthat (>= 3.0.0)
Depends:
Expand Down
20 changes: 15 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import(cowplot)
import(data.table)
import(dplyr)
import(gdata)
import(ggExtra)
import(ggplot2)
import(ggpubr)
import(ggrepel)
Expand All @@ -48,14 +47,19 @@ import(scales)
import(tidyverse)
import(tools)
import(utils)
importFrom(BiocParallel,SerialParam)
importFrom(ComplexHeatmap,pheatmap)
importFrom(RColorBrewer,brewer.pal)
importFrom(RColorBrewer,brewer.pal.info)
importFrom(Seurat,AddMetaData)
importFrom(Seurat,CreateAssayObject)
importFrom(Seurat,DotPlot)
importFrom(Seurat,FindVariableFeatures)
importFrom(Seurat,Idents)
importFrom(Seurat,RunPCA)
importFrom(Seurat,RunTSNE)
importFrom(Seurat,RunUMAP)
importFrom(Seurat,SCTransform)
importFrom(Seurat,as.SingleCellExperiment)
importFrom(SingleR,SingleR)
importFrom(colorspace,RGB)
Expand All @@ -75,20 +79,18 @@ importFrom(dplyr,mutate)
importFrom(dplyr,mutate_if)
importFrom(dplyr,pull)
importFrom(dplyr,relocate)
importFrom(dplyr,rename)
importFrom(dplyr,row_number)
importFrom(dplyr,select)
importFrom(dplyr,summarise)
importFrom(ggExtra,ggMarginal)
importFrom(ggplot2,aes)
importFrom(ggplot2,coord_fixed)
importFrom(ggplot2,geom_hline)
importFrom(ggplot2,geom_point)
importFrom(ggplot2,geom_vline)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,ggtitle)
importFrom(ggplot2,scale_color_identity)
importFrom(ggplot2,scale_y_reverse)
importFrom(ggplot2,theme)
importFrom(ggplot2,theme_bw)
importFrom(ggplot2,theme_classic)
importFrom(ggplot2,xlab)
importFrom(ggplot2,ylab)
Expand All @@ -97,8 +99,13 @@ importFrom(ggpubr,annotate_figure)
importFrom(ggpubr,get_legend)
importFrom(ggpubr,ggarrange)
importFrom(grDevices,colorRampPalette)
importFrom(grid,gTree)
importFrom(grid,grid.draw)
importFrom(grid,grid.newpage)
importFrom(grid,grobHeight)
importFrom(grid,textGrob)
importFrom(gridExtra,arrangeGrob)
importFrom(gridExtra,tableGrob)
importFrom(htmlwidgets,saveWidget)
importFrom(magrittr,"%>%")
importFrom(plotly,as_widget)
Expand All @@ -110,9 +117,12 @@ importFrom(scales,rescale)
importFrom(stats,as.hclust)
importFrom(stats,hclust)
importFrom(stats,kmeans)
importFrom(stats,mad)
importFrom(stats,median)
importFrom(stats,quantile)
importFrom(stringr,str_replace_all)
importFrom(stringr,str_sort)
importFrom(stringr,str_split_fixed)
importFrom(stringr,str_to_title)
importFrom(stringr,str_wrap)
importFrom(tibble,deframe)
Expand Down
3 changes: 2 additions & 1 deletion R/3D_tSNE.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ tSNE3D <- function(object,
htmlwidgets::saveWidget(as_widget(fig), filename, selfcontained = TRUE)
}

tsne.results <- list("plot" = fig, "data" = tsne.df)
tsne.results <- list( "data" = tsne.df,
"plots" = fig)
return(tsne.results)
}
88 changes: 88 additions & 0 deletions R/AggregateCounts.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
##' @title Aggregate Counts (Pseudobulk)
##' @description Compute pseudobulk expression by averaging expression across groups
##' defined by one or more metadata columns, and return a tidy table.
##' @details Uses Seurat's `AverageExpression()` on the `SCT` assay to compute
##' group-wise average expression for each feature. Also produces a
##' bar plot (via `ggplot2`/`plotly`) showing the number of cells per
##' pseudobulk group and warns if any group contains only one cell.
##'
##' @param object Seurat-class object.
##' @param var.group Character vector of metadata column names used to define
##' pseudobulk groups. When multiple columns are supplied, an
##' interaction of these columns defines the groups.
##' @param slot Character name of the assay data layer passed to
##' `AverageExpression()` (e.g., "data", "counts", or "scale.data").
##'
##' @return A data.frame of pseudobulk expression with columns `Gene` followed by
##' one column per pseudobulk group. Column names are sanitized to
##' contain only alphanumeric/underscore characters.
##'
##' @import Seurat
##' @import tidyverse
##' @import ggplot2
##' @import plotly
##' @importFrom dplyr select
##'
##' @export

aggregateCounts <- function(object,
var.group,
slot){


## --------------- ##
## Main Code Block ##
## --------------- ##

pseudobulk <- AverageExpression(object,
return.seurat = FALSE,
assay = "SCT",
group.by = var.group,
slot = slot)[[1]] %>%
as.data.frame.matrix()

pseudobulk$Gene <- rownames(pseudobulk)
pseudobulk <- pseudobulk %>% select("Gene", everything())
rownames(pseudobulk) <- NULL

# Further processing of column names
colnames(pseudobulk) <- gsub("\\W","_",colnames(pseudobulk))

# Return Table/Figure that gives statistics on
# Number of Cells in each group/new sample
# Distribution of cell Counts in each group/new sample
meta <- object@meta.data[,var.group]

# check that columns are all factors / categorical
char_or_factor_cols <- sapply(meta, function(x) is.character(x) || is.factor(x) || is.logical(x))

# do plots and tables if all columns are factors or characters
if(all(char_or_factor_cols)){
meta$interaction <- gsub("\\W","_",interaction(meta))

df <- as.data.frame(table(pseudobulk_group = meta$interaction)) %>% filter(Freq != 0)
# sort the table by the number of cells in each group
df <- df[order(df$Freq, decreasing = F),]

if(any(df$Freq == 1)){
single_counts <- df$pseudobulk_group[df$Freq == 1]
# sprintf, make custom warning message with %s as placeholder for single count groups
warning(sprintf(
"Some groups have only 1 cell. It is recommended to have at least 2 cells in each group.\nAffected groups: %s",
paste(single_counts, collapse = ", ")
))
}

p <- ggplotly(ggplot(df, aes(x = pseudobulk_group, y = Freq)) +
geom_bar(stat = "identity", position = "stack") +
labs(y = "Counts", x = "Pseudobulk Groups", title = "Number of Cells in each Pseudobulk Group") +
theme(axis.text.x = element_text(angle = 90, hjust = 1)))

print(p)

} else {
stop("All columns in var.group must be factors or characters")
}

return(pseudobulk)
}
4 changes: 2 additions & 2 deletions R/Annotate_Cell_Types.R
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ annotateCellTypes <- function(object,
# Returning Seurat Object and 2 plots:
return(list(
"object" = object,
"p1" = p1,
"p2" = p2
"plots"=list("p1" = p1,
"p2" = p2)
))
}
12 changes: 9 additions & 3 deletions R/Color_by_Gene.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ colorByGene <- function(object,

print(object)
# checking for samples
samples = eval(parse(text = gsub('\\[\\]', 'c()', samples.to.include)))
if(any(grepl('c\\(|\\[\\]',samples))) {
samples = eval(parse(text = gsub('\\[\\]', 'c()', samples)))
}else{
samples=samples
}
# if none specified, using ALL
if (length(samples) == 0) {
samples = unique(object@meta.data$orig.ident)
Expand Down Expand Up @@ -218,11 +222,13 @@ colorByGene <- function(object,
### plots <- gridExtra::grid.arrange(grobs=grob,nrow=n,newpage=F)

if (return.seurat.object) {
result.list <- list("object" = object, "plot" = grob)
result.list <- list("object" = object,
"plots" = grob)
return(result.list)
} else {
gene = as.data.frame(gene)
result.list <- list("object" = gene, "plot" = grob)
result.list <- list("data" = list("gene_table" = gene),
"plots" = grob)
return(result.list)
}

Expand Down
Loading
Loading