This page was generated on 2023-04-11 14:50:27 -0400 (Tue, 11 Apr 2023).
R version 4.2.3 (2023-03-15) -- "Shortstop Beagle"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(testthat)
> library(spatialLIBD)
Loading required package: SpatialExperiment
Loading required package: SingleCellExperiment
Loading required package: SummarizedExperiment
Loading required package: MatrixGenerics
Loading required package: matrixStats
Attaching package: 'MatrixGenerics'
The following objects are masked from 'package:matrixStats':
colAlls, colAnyNAs, colAnys, colAvgsPerRowSet, colCollapse,
colCounts, colCummaxs, colCummins, colCumprods, colCumsums,
colDiffs, colIQRDiffs, colIQRs, colLogSumExps, colMadDiffs,
colMads, colMaxs, colMeans2, colMedians, colMins, colOrderStats,
colProds, colQuantiles, colRanges, colRanks, colSdDiffs, colSds,
colSums2, colTabulates, colVarDiffs, colVars, colWeightedMads,
colWeightedMeans, colWeightedMedians, colWeightedSds,
colWeightedVars, rowAlls, rowAnyNAs, rowAnys, rowAvgsPerColSet,
rowCollapse, rowCounts, rowCummaxs, rowCummins, rowCumprods,
rowCumsums, rowDiffs, rowIQRDiffs, rowIQRs, rowLogSumExps,
rowMadDiffs, rowMads, rowMaxs, rowMeans2, rowMedians, rowMins,
rowOrderStats, rowProds, rowQuantiles, rowRanges, rowRanks,
rowSdDiffs, rowSds, rowSums2, rowTabulates, rowVarDiffs, rowVars,
rowWeightedMads, rowWeightedMeans, rowWeightedMedians,
rowWeightedSds, rowWeightedVars
Loading required package: GenomicRanges
Loading required package: stats4
Loading required package: BiocGenerics
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:stats':
IQR, mad, sd, var, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, aperm, append,
as.data.frame, basename, cbind, colnames, dirname, do.call,
duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
lapply, mapply, match, mget, order, paste, pmax, pmax.int, pmin,
pmin.int, rank, rbind, rownames, sapply, setdiff, sort, table,
tapply, union, unique, unsplit, which.max, which.min
Loading required package: S4Vectors
Attaching package: 'S4Vectors'
The following objects are masked from 'package:base':
I, expand.grid, unname
Loading required package: IRanges
Loading required package: GenomeInfoDb
Loading required package: Biobase
Welcome to Bioconductor
Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.
Attaching package: 'Biobase'
The following object is masked from 'package:MatrixGenerics':
rowMedians
The following objects are masked from 'package:matrixStats':
anyMissing, rowMedians
>
> test_check("spatialLIBD")
rgstr_> ## Ensure reproducibility of example data
rgstr_> set.seed(20220907)
rgstr_> ## Generate example data
rgstr_> sce <- scuttle::mockSCE()
rgstr_> ## Add some sample IDs
rgstr_> sce$sample_id <- sample(LETTERS[1:5], ncol(sce), replace = TRUE)
rgstr_> ## Add a sample-level covariate: age
rgstr_> ages <- rnorm(5, mean = 20, sd = 4)
rgstr_> names(ages) <- LETTERS[1:5]
rgstr_> sce$age <- ages[sce$sample_id]
rgstr_> ## Add gene-level information
rgstr_> rowData(sce)$ensembl <- paste0("ENSG", seq_len(nrow(sce)))
rgstr_> rowData(sce)$gene_name <- paste0("gene", seq_len(nrow(sce)))
rgstr_> ## Pseudo-bulk
rgstr_> sce_pseudo <- registration_pseudobulk(sce, "Cell_Cycle", "sample_id", c("age"), min_ncells = NULL)
rgstr_> colData(sce_pseudo)
DataFrame with 20 rows and 8 columns
Mutation_Status Cell_Cycle Treatment sample_id age
<character> <character> <character> <character> <numeric>
A_G0 NA G0 NA A 19.1872
B_G0 NA G0 NA B 25.3496
C_G0 NA G0 NA C 24.1802
D_G0 NA G0 NA D 15.5211
E_G0 NA G0 NA E 20.9701
... ... ... ... ... ...
A_S NA S NA A 19.1872
B_S NA S NA B 25.3496
C_S NA S NA C 24.1802
D_S NA S NA D 15.5211
E_S NA S NA E 20.9701
registration_variable registration_sample_id ncells
<character> <character> <integer>
A_G0 G0 A 8
B_G0 G0 B 13
C_G0 G0 C 9
D_G0 G0 D 7
E_G0 G0 E 10
... ... ... ...
A_S S A 12
B_S S B 8
C_S S C 7
D_S S D 14
E_S S E 11
rgstr_> ## Ensure reproducibility of example data
rgstr_> set.seed(20220907)
rgstr_> ## Generate example data
rgstr_> sce <- scuttle::mockSCE()
rgstr_> ## Add some sample IDs
rgstr_> sce$sample_id <- sample(LETTERS[1:5], ncol(sce), replace = TRUE)
rgstr_> ## Add a sample-level covariate: age
rgstr_> ages <- rnorm(5, mean = 20, sd = 4)
rgstr_> names(ages) <- LETTERS[1:5]
rgstr_> sce$age <- ages[sce$sample_id]
rgstr_> ## Add gene-level information
rgstr_> rowData(sce)$ensembl <- paste0("ENSG", seq_len(nrow(sce)))
rgstr_> rowData(sce)$gene_name <- paste0("gene", seq_len(nrow(sce)))
rgstr_> ## Pseudo-bulk
rgstr_> sce_pseudo <- registration_pseudobulk(sce, "Cell_Cycle", "sample_id", c("age"), min_ncells = NULL)
rgstr_> colData(sce_pseudo)
DataFrame with 20 rows and 8 columns
Mutation_Status Cell_Cycle Treatment sample_id age
<character> <character> <character> <character> <numeric>
A_G0 NA G0 NA A 19.1872
B_G0 NA G0 NA B 25.3496
C_G0 NA G0 NA C 24.1802
D_G0 NA G0 NA D 15.5211
E_G0 NA G0 NA E 20.9701
... ... ... ... ... ...
A_S NA S NA A 19.1872
B_S NA S NA B 25.3496
C_S NA S NA C 24.1802
D_S NA S NA D 15.5211
E_S NA S NA E 20.9701
registration_variable registration_sample_id ncells
<character> <character> <integer>
A_G0 G0 A 8
B_G0 G0 B 13
C_G0 G0 C 9
D_G0 G0 D 7
E_G0 G0 E 10
... ... ... ...
A_S S A 12
B_S S B 8
C_S S C 7
D_S S D 14
E_S S E 11
rgst__> example("registration_model", package = "spatialLIBD")
rgstr_> example("registration_pseudobulk", package = "spatialLIBD")
rgstr_> ## Ensure reproducibility of example data
rgstr_> set.seed(20220907)
rgstr_> ## Generate example data
rgstr_> sce <- scuttle::mockSCE()
rgstr_> ## Add some sample IDs
rgstr_> sce$sample_id <- sample(LETTERS[1:5], ncol(sce), replace = TRUE)
rgstr_> ## Add a sample-level covariate: age
rgstr_> ages <- rnorm(5, mean = 20, sd = 4)
rgstr_> names(ages) <- LETTERS[1:5]
rgstr_> sce$age <- ages[sce$sample_id]
rgstr_> ## Add gene-level information
rgstr_> rowData(sce)$ensembl <- paste0("ENSG", seq_len(nrow(sce)))
rgstr_> rowData(sce)$gene_name <- paste0("gene", seq_len(nrow(sce)))
rgstr_> ## Pseudo-bulk
rgstr_> sce_pseudo <- registration_pseudobulk(sce, "Cell_Cycle", "sample_id", c("age"), min_ncells = NULL)
rgstr_> colData(sce_pseudo)
DataFrame with 20 rows and 8 columns
Mutation_Status Cell_Cycle Treatment sample_id age
<character> <character> <character> <character> <numeric>
A_G0 NA G0 NA A 19.1872
B_G0 NA G0 NA B 25.3496
C_G0 NA G0 NA C 24.1802
D_G0 NA G0 NA D 15.5211
E_G0 NA G0 NA E 20.9701
... ... ... ... ... ...
A_S NA S NA A 19.1872
B_S NA S NA B 25.3496
C_S NA S NA C 24.1802
D_S NA S NA D 15.5211
E_S NA S NA E 20.9701
registration_variable registration_sample_id ncells
<character> <character> <integer>
A_G0 G0 A 8
B_G0 G0 B 13
C_G0 G0 C 9
D_G0 G0 D 7
E_G0 G0 E 10
... ... ... ...
A_S S A 12
B_S S B 8
C_S S C 7
D_S S D 14
E_S S E 11
rgstr_> registration_mod <- registration_model(sce_pseudo, "age")
rgstr_> head(registration_mod)
registration_variableG0 registration_variableG1 registration_variableG2M
A_G0 1 0 0
B_G0 1 0 0
C_G0 1 0 0
D_G0 1 0 0
E_G0 1 0 0
A_G1 0 1 0
registration_variableS age
A_G0 0 19.18719
B_G0 0 25.34965
C_G0 0 24.18019
D_G0 0 15.52107
E_G0 0 20.97006
A_G1 0 19.18719
rgst__> block_cor <- registration_block_cor(sce_pseudo, registration_mod)
[ FAIL 0 | WARN 0 | SKIP 0 | PASS 9 ]
>
> proc.time()
user system elapsed
19.509 0.937 20.428