Skip to content

Commit 6148948

Browse files
committed
update unit tests rev2
1 parent 4be953b commit 6148948

29 files changed

Lines changed: 1530 additions & 330 deletions

.Rbuildignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
^.*\.Rproj$
22
^\.Rproj\.user$
3+
^\.github$
4+
^docs$
5+
^Dockerfile$
6+
^Dockerfiles/.*$
7+
^Conda_Recipe/.*$

DESCRIPTION

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ Description: A set of functions for analyzing single-cell RNA-seq data using the
1515
and further visualizations and analysis based on user input. This package can
1616
be run both in a docker container and in user-friendly web-based interactive
1717
notebooks (NIDAP, Palantir Foundry).
18-
License: MIT
18+
License: MIT + file LICENSE
1919
Encoding: UTF-8
2020
Roxygen: list(markdown = TRUE)
2121
RoxygenNote: 7.3.3
2222
Suggests:
23-
testthat (>= 3.0.0)
23+
testthat (>= 3.0.0),
24+
knitr,
25+
rmarkdown,
26+
shiny
27+
VignetteBuilder: knitr
2428
Depends:
2529
R (>= 4.0)
2630
Imports:
@@ -86,4 +90,5 @@ Imports:
8690
tidyr,
8791
htmlwidgets,
8892
scDblFinder
93+
, BiocParallel
8994
Config/testthat/edition: 3

LICENSE

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,2 @@
1-
MIT License
2-
3-
Copyright (c) 2024 NIDAP Community
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
1+
YEAR: 2024
2+
COPYRIGHT HOLDER: NIDAP Community

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 NIDAP Community
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

NAMESPACE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
export(aggregateCounts)
34
export(annotateCellTypes)
45
export(appendMetadataToSeuratObject)
56
export(colorByGene)
@@ -40,6 +41,7 @@ import(harmony)
4041
import(httr)
4142
import(jsonlite)
4243
import(parallel)
44+
import(plotly)
4345
import(quantmod)
4446
import(reshape2)
4547
import(rlang)
@@ -85,12 +87,16 @@ importFrom(dplyr,select)
8587
importFrom(dplyr,summarise)
8688
importFrom(ggExtra,ggMarginal)
8789
importFrom(ggplot2,aes)
90+
importFrom(ggplot2,coord_fixed)
91+
importFrom(ggplot2,geom_hline)
8892
importFrom(ggplot2,geom_point)
8993
importFrom(ggplot2,geom_vline)
9094
importFrom(ggplot2,ggplot)
9195
importFrom(ggplot2,ggtitle)
96+
importFrom(ggplot2,scale_color_identity)
9297
importFrom(ggplot2,scale_y_reverse)
9398
importFrom(ggplot2,theme)
99+
importFrom(ggplot2,theme_bw)
94100
importFrom(ggplot2,theme_classic)
95101
importFrom(ggplot2,xlab)
96102
importFrom(ggplot2,ylab)
@@ -100,10 +106,12 @@ importFrom(ggpubr,get_legend)
100106
importFrom(ggpubr,ggarrange)
101107
importFrom(grDevices,colorRampPalette)
102108
importFrom(grid,gTree)
109+
importFrom(grid,gpar)
103110
importFrom(grid,grid.draw)
104111
importFrom(grid,grid.newpage)
105112
importFrom(grid,grobHeight)
106113
importFrom(grid,textGrob)
114+
importFrom(grid,unit)
107115
importFrom(gridExtra,arrangeGrob)
108116
importFrom(gridExtra,tableGrob)
109117
importFrom(htmlwidgets,saveWidget)

R/AggregateCounts.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ aggregateCounts <- function(object,
3838
return.seurat = FALSE,
3939
assay = "SCT",
4040
group.by = var.group,
41-
slot = slot)[[1]] %>%
41+
layer = slot)[[1]] %>%
4242
as.data.frame.matrix()
4343

4444
pseudobulk$Gene <- rownames(pseudobulk)

R/Color_by_Genes_Automatic.R

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@
3232
#' @import ggplot2
3333
#'
3434
#' @export
35-
#' @example Do not run: colorByMarkerTable(object = seurat,
36-
#' samples.subset = c("mouse1","mouse2),
37-
#' samples.to.display = c("mouse1"),
38-
#' marker.table = immuneCellMarkers,
39-
#' cells.of.interest = c("CD4","Treg")
40-
#' )
35+
#' @examples
36+
#' \dontrun{
37+
#' colorByMarkerTable(
38+
#' object = seurat,
39+
#' samples.subset = c("mouse1", "mouse2"),
40+
#' samples.to.display = c("mouse1"),
41+
#' marker.table = immuneCellMarkers,
42+
#' cells.of.interest = c("CD4", "Treg")
43+
#' )
44+
#' }
4145

4246
#' @return arranged grob of dimension reduction plots colored by individual
4347
#' marker expression

R/Dual_Labeling.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,15 @@
4848
#' @param display.unscaled.values Set to TRUE if you want to view the unscaled
4949
#' gene/protein expression values (Default is FALSE)
5050

51-
#' @importFrom Seurat
51+
#' @import Seurat
5252
#' @importFrom scales rescale
53-
#' @importFrom gridExtra arrangeGrob
54-
#' @importFrom grid grid.draw
53+
#' @importFrom gridExtra arrangeGrob tableGrob
54+
#' @importFrom grid grid.draw textGrob gpar unit
5555
#' @importFrom dplyr arrange mutate case_when
5656
#' @importFrom magrittr %>%
5757
#' @importFrom stats quantile
58-
#' @importFrom ggplot2 ggplot geom_point theme_classic xlab ylab geom_vline
58+
#' @importFrom ggplot2 ggplot geom_point theme_classic xlab ylab geom_vline geom_hline scale_color_identity theme_bw coord_fixed ggtitle aes
5959
#' @importFrom ggExtra ggMarginal
60-
#' geom_hline scale_color_identity theme_bw coord_fixed ggtitle aes
6160
#'
6261
#' @export
6362
#'

R/Harmony.R

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@
2222
#' @import ggplot2
2323
#'
2424
#' @export
25-
#' @example Do not run: harmonyBatchCorrect(object = seurat,
26-
#' nvar = 2000,
27-
#' genes.to.add = c("Cd4","Cd8a"),
28-
#' group.by.var = "Mouse_Origin",
29-
#' npc = 20)
25+
#' @examples
26+
#' \dontrun{
27+
#' harmonyBatchCorrect(
28+
#' object = seurat,
29+
#' nvar = 2000,
30+
#' genes.to.add = c("Cd4", "Cd8a"),
31+
#' group.by.var = "Mouse_Origin",
32+
#' npc = 20
33+
#' )
34+
#' }
3035

3136
#' @return A list: adj.object with harmony-adjusted gene expression (SCT slot)
3237
#' adj.tsne: harmonized tSNE plot

R/ModuleScore.R

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,35 @@
7171
#' @importFrom dplyr select
7272
#'
7373
#' @export
74-
#' @example Do not run: moduleScore(object = seuratObject,
75-
#' marker.table = immuneCellMarkers,
76-
#' celltypes = c("CD4_T","Treg",Monocytes"),
77-
#' ms_threshold = c("CD4_T 0.1","Treg 0.4", "Monocytes 0.3"),
78-
#' multi.lvl = FALSE
79-
#' )
80-
#'
81-
#' @example Do not run: moduleScore(object = seuratObject,
82-
#' marker.table = immuneCellMarkers,
83-
#' celltypes = c("CD4_T","Treg",Monocytes"),
84-
#' ms_threshold = c("CD4_T 0.1","Treg 0.4", "Monocytes 0.3"),
85-
#' general.class = c("CD_T","Monocytes"),
86-
#' multi.lvl = TRUE,
87-
#' lvl.df = parentChildTable
88-
#' )
74+
#' @examples
75+
#' \dontrun{
76+
#' modScore(
77+
#' object = seuratObject,
78+
#' marker.table = immuneCellMarkers,
79+
#' use_columns = c("CD4_T", "Treg", "Monocytes"),
80+
#' ms_threshold = c("CD4_T 0.1", "Treg 0.4", "Monocytes 0.3"),
81+
#' general.class = c("CD4_T", "Monocytes"),
82+
#' multi.lvl = FALSE
83+
#' )
84+
#'
85+
#' modScore(
86+
#' object = seuratObject,
87+
#' marker.table = immuneCellMarkers,
88+
#' use_columns = c("CD4_T", "Treg", "Monocytes"),
89+
#' ms_threshold = c("CD4_T 0.1", "Treg 0.4", "Monocytes 0.3"),
90+
#' general.class = c("CD4_T", "Monocytes"),
91+
#' multi.lvl = TRUE,
92+
#' lvl.df = parentChildTable
93+
#' )
94+
#' }
8995

9096
#' @return List containing annotated dimension plot with ModuleScore
9197
#' distribution of cell marker gene, Seurat Object with cell
9298
#' classification metadata
9399

94100
modScore <- function(object,
95101
marker.table,
102+
group_var = "orig.ident",
96103
use_columns,
97104
ms_threshold,
98105
general.class,
@@ -231,7 +238,7 @@ modScore <- function(object,
231238
umap.pos <- clusmat %>% group_by(clusid) %>% dplyr::summarise(umap1.mean = mean(umap1), umap2.mean = mean(umap2))
232239
title = as.character(m)
233240
clusmat <- clusmat %>% dplyr::arrange(clusid)
234-
clusid.df <- data.frame(id = object@meta.data$orig.ident,
241+
clusid.df <- data.frame(id = object@meta.data[[group_var]],
235242
ModuleScore = object@meta.data[[m]])
236243

237244
g <- ggplot(clusmat, aes(x = umap1, y = umap2)) + theme_bw() +
@@ -240,7 +247,7 @@ modScore <- function(object,
240247
1), limits = c(0, 1))) + guides(colour = guide_legend(override.aes = list(size = 5, alpha = 1))) + theme(panel.grid.major = element_blank(),
241248
panel.grid.minor = element_blank(), panel.background = element_blank()) + xlab("tsne-1") + ylab("tsne-2")
242249

243-
g1 <- RidgePlot(object, features = m, group.by = "orig.ident") +
250+
g1 <- RidgePlot(object, features = m, group.by = group_var) +
244251
theme(legend.position = "none", title = element_blank(),
245252
axis.text.x = element_text(size = gradient.ft.size)) +
246253
geom_vline(xintercept = numeric_threshold[celltype_name], linetype = "dashed",

0 commit comments

Comments
 (0)