From f34fb00b199d4912eb179a6f77ea48f1fa60aff1 Mon Sep 17 00:00:00 2001 From: "Paul L. Maurizio" Date: Tue, 18 Jul 2023 12:05:57 -0400 Subject: [PATCH 1/7] Update differential_expression.R p.adjust should use all the features in the object, not just those passing the logfc threshold --- R/differential_expression.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/differential_expression.R b/R/differential_expression.R index 55a5f98..b7d584b 100644 --- a/R/differential_expression.R +++ b/R/differential_expression.R @@ -335,7 +335,7 @@ DE_MAST_RE_seurat = function( "p_val" = summaryCond$datatable[contrast=='groupGroup1' & component=='H', `Pr(>Chisq)`], fc.results[vec_logical_features,]) #setDF(summaryCond$datatable[contrast=='groupGroup1' & component=='logFC', .(coef)]) - de.results$p_val_adj = p.adjust(de.results$p_val, method=p.adjust.method, n=length(vec_logical_features)) + de.results$p_val_adj = p.adjust(de.results$p_val, method=p.adjust.method, n=length(features)) de.results = de.results[order(de.results$p_val, -de.results[[fc.name]]),] From df6421b4a3e8a1104f08a9517c6f850e4b0fa469 Mon Sep 17 00:00:00 2001 From: "Paul L. Maurizio" Date: Tue, 18 Jul 2023 12:33:48 -0400 Subject: [PATCH 2/7] Update differential_expression.R --- R/differential_expression.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/differential_expression.R b/R/differential_expression.R index b7d584b..a74c1bf 100644 --- a/R/differential_expression.R +++ b/R/differential_expression.R @@ -333,11 +333,12 @@ DE_MAST_RE_seurat = function( de.results <- data.frame( "p_val" = summaryCond$datatable[contrast=='groupGroup1' & component=='H', `Pr(>Chisq)`], + "z_score" = summaryCond$datatable[contrast=='groupGroup1' & component=='H', `z`], fc.results[vec_logical_features,]) #setDF(summaryCond$datatable[contrast=='groupGroup1' & component=='logFC', .(coef)]) de.results$p_val_adj = p.adjust(de.results$p_val, method=p.adjust.method, n=length(features)) - de.results = de.results[order(de.results$p_val, -de.results[[fc.name]]),] + de.results = de.results[order(de.results$z_score),] return(de.results) } From 27d72103143e43f9dff3a1f7019784877dae9e5f Mon Sep 17 00:00:00 2001 From: "Paul L. Maurizio" Date: Tue, 18 Jul 2023 13:11:49 -0400 Subject: [PATCH 3/7] Update differential_expression.R --- R/differential_expression.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/differential_expression.R b/R/differential_expression.R index a74c1bf..6d05ac5 100644 --- a/R/differential_expression.R +++ b/R/differential_expression.R @@ -332,8 +332,8 @@ DE_MAST_RE_seurat = function( # https://github.com/kdzimm/PseudoreplicationPaper/blob/master/Type_1_Error/Type%201%20-%20MAST%20RE.Rmd de.results <- data.frame( - "p_val" = summaryCond$datatable[contrast=='groupGroup1' & component=='H', `Pr(>Chisq)`], - "z_score" = summaryCond$datatable[contrast=='groupGroup1' & component=='H', `z`], + "p_val" = summaryCond$datatable[contrast=='groupGroup1' & component=='H', "Pr(>Chisq)"], + "z_score" = summaryCond$datatable[contrast=='groupGroup1' & component=='H', "z"], fc.results[vec_logical_features,]) #setDF(summaryCond$datatable[contrast=='groupGroup1' & component=='logFC', .(coef)]) de.results$p_val_adj = p.adjust(de.results$p_val, method=p.adjust.method, n=length(features)) From a1e0d17a0f4957465c47dd5efe9807b2072b8702 Mon Sep 17 00:00:00 2001 From: "Paul L. Maurizio" Date: Tue, 18 Jul 2023 15:19:01 -0400 Subject: [PATCH 4/7] Update DESCRIPTION --- DESCRIPTION | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DESCRIPTION b/DESCRIPTION index 75b9b74..c5973e6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,6 +11,8 @@ LazyData: true Suggests: testthat (>= 3.0.0) Config/testthat/edition: 3 +Depends: + data.table Imports: Seurat, MAST, From 4a06edc8704430d26d447dc744713401b3df6d5e Mon Sep 17 00:00:00 2001 From: "Paul L. Maurizio" Date: Tue, 18 Jul 2023 15:19:22 -0400 Subject: [PATCH 5/7] Update NAMESPACE --- NAMESPACE | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index d75f824..dc5d4a4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1 +1,17 @@ -exportPattern("^[[:alpha:]]+") +Generated by roxygen2: do not edit by hand + +export(.countsperclus) +export(DE_MAST_RE_seurat) +export(dim_red_est) +export(geneset_VIF) +export(geneset_embed) +export(geneset_embed_list_seurat) +export(plot_barIdentGroup) +export(plot_network) +export(plot_vlnGrid) +export(prep_HTO_q_area_plot) +export(prep_intrahash_doub) +export(prep_qc_rna) +export(remap) +export(utils_big_as.matrix) +importFrom(Matrix,rowSums) From 9377869349a1fb9a53c6ef4d1da2283360f7c81b Mon Sep 17 00:00:00 2001 From: mauriziopaul Date: Tue, 18 Jul 2023 16:05:44 -0400 Subject: [PATCH 6/7] removed problematic utils Rd files, updated DESCRIPTION and NAMESPACE --- .Rbuildignore | 2 ++ .github/ISSUE_TEMPLATE/bug_report.md | 38 ----------------------- .github/ISSUE_TEMPLATE/feature_request.md | 20 ------------ .gitignore | 4 +++ DESCRIPTION | 4 +-- NAMESPACE | 21 +++---------- man/f_VIF.Rd | 2 +- man/utils_big_as.matrix.Rd | 25 --------------- man/utils_detachAllPkgs.Rd | 20 ------------ man/utils_detectCoresRAM.Rd | 23 -------------- man/utils_dlFile.Rd | 24 -------------- man/utils_printObjectSizes.Rd | 20 ------------ man/utils_saveMeta.Rd | 33 -------------------- man/utils_verboseFnc.Rd | 22 ------------- 14 files changed, 13 insertions(+), 245 deletions(-) create mode 100644 .Rbuildignore delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .gitignore delete mode 100644 man/utils_big_as.matrix.Rd delete mode 100644 man/utils_detachAllPkgs.Rd delete mode 100644 man/utils_detectCoresRAM.Rd delete mode 100644 man/utils_dlFile.Rd delete mode 100644 man/utils_printObjectSizes.Rd delete mode 100644 man/utils_saveMeta.Rd delete mode 100644 man/utils_verboseFnc.Rd diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..91114bf --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,2 @@ +^.*\.Rproj$ +^\.Rproj\.user$ diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index dd84ea7..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index bbcbbe7..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b6a065 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata diff --git a/DESCRIPTION b/DESCRIPTION index c5973e6..52c4e46 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,11 +16,11 @@ Depends: Imports: Seurat, MAST, - data.table, ggplot2, patchwork, parallel, sessioninfo, utils, - magrittr + magrittr, + methods RoxygenNote: 7.1.1 diff --git a/NAMESPACE b/NAMESPACE index dc5d4a4..c204e62 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,17 +1,4 @@ -Generated by roxygen2: do not edit by hand - -export(.countsperclus) -export(DE_MAST_RE_seurat) -export(dim_red_est) -export(geneset_VIF) -export(geneset_embed) -export(geneset_embed_list_seurat) -export(plot_barIdentGroup) -export(plot_network) -export(plot_vlnGrid) -export(prep_HTO_q_area_plot) -export(prep_intrahash_doub) -export(prep_qc_rna) -export(remap) -export(utils_big_as.matrix) -importFrom(Matrix,rowSums) +importFrom("grDevices", "colorRampPalette") + importFrom("methods", "is") + importFrom("stats", "aggregate", "as.formula", "cor", "p.adjust", + "pnorm", "quantile", "relevel", "sd") diff --git a/man/f_VIF.Rd b/man/f_VIF.Rd index 2e7613d..e5c37b8 100644 --- a/man/f_VIF.Rd +++ b/man/f_VIF.Rd @@ -19,7 +19,7 @@ Utility function to compute Variance Inflation Factors for gene sets using an ex in order to account for inter-gene correlation in gene sets derived from expression data } \examples{ -list_vec_VIF <- f_VIF(datExpr=mat_counts, list_genesets=mylist) +%list_vec_VIF <- f_VIF(datExpr=mat_counts, list_genesets=mylist) } \references{ modified from https://rdrr.io/bioc/qusage/src/R/qusage.R diff --git a/man/utils_big_as.matrix.Rd b/man/utils_big_as.matrix.Rd deleted file mode 100644 index 98a9c74..0000000 --- a/man/utils_big_as.matrix.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{utils_big_as.matrix} -\alias{utils_big_as.matrix} -\title{Convert a large sparse matrix into a dense matrix without errors} -\usage{ -utils_big_as.matrix(sparseMat, n_slices_init = 1, verbose = T) -} -\arguments{ -\item{sparseMat}{a big sparse matrix of a type coercible to dense Matrix::Matrix} - -\item{n_slices_init}{initial number of slices. Default value 1, i.e. whole matrix} - -\item{verbose}{print progress} -} -\value{ -a dense matrix -} -\description{ -Avoid the following error -. Error in asMethod(object) : -. Cholmod error 'problem too large' at file ../Core/cholmod_dense.c, -. by slicing the matrix into submatrices, converting and cbinding them -. Increases number of slices until they succeed. -} diff --git a/man/utils_detachAllPkgs.Rd b/man/utils_detachAllPkgs.Rd deleted file mode 100644 index 42a15a8..0000000 --- a/man/utils_detachAllPkgs.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{utils_detachAllPkgs} -\alias{utils_detachAllPkgs} -\title{Detach all packages from current session} -\usage{ -utils_detachAllPkgs() -} -\value{ -None -} -\description{ -Detach all packages from current session -} -\examples{ -utils_detachAllPkgs() -} -\references{ -https://stackoverflow.com/questions/7505547/detach-all-packages-while-working-in-r -} diff --git a/man/utils_detectCoresRAM.Rd b/man/utils_detectCoresRAM.Rd deleted file mode 100644 index a6e0873..0000000 --- a/man/utils_detectCoresRAM.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{utils_detectCoresRAM} -\alias{utils_detectCoresRAM} -\title{Detect cores with RAM constraints} -\usage{ -utils_detectCoresRAM(Gb_max = 250, additional_Gb = 1) -} -\arguments{ -\item{Gb_max}{ceiling on session memory usage in Gb, assuming that each worker duplicates the session memory} - -\item{additional_Gb}{max additional memory requirement for new (temporary) objects created within a parallel session} -} -\value{ -max number of cores (integer) -} -\description{ -Given a ceiling on RAM to use and predicted extra RAM needed in -. each worker in addition to current usage, return safe number of cores -} -\examples{ -n_cores_use = utils_detectCoresRAM(Gb_max=250,additional_Gb=1) -} diff --git a/man/utils_dlFile.Rd b/man/utils_dlFile.Rd deleted file mode 100644 index b7bf428..0000000 --- a/man/utils_dlFile.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{utils_dlFile} -\alias{utils_dlFile} -\title{Check if a file matches given hash, else download it and check again} -\usage{ -utils_dlFile(url, destfile, correct_checksum) -} -\arguments{ -\item{url}{passed to download.file()} - -\item{destfile}{passed to download.file().} - -\item{correct_checksum}{file md5 checksum} -} -\value{ - -} -\description{ -Check if a file matches given hash, else download it and check again -} -\examples{ -utils_dlFile(url=https:/.mysite.com/files/test.csv, destfile="./data", correct_checksum="2c3294272a968ffc91c0c2af2c296988") -} diff --git a/man/utils_printObjectSizes.Rd b/man/utils_printObjectSizes.Rd deleted file mode 100644 index b8dadca..0000000 --- a/man/utils_printObjectSizes.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{utils_printObjectSizes} -\alias{utils_printObjectSizes} -\title{Show the memory size of the top n objects} -\usage{ -utils_printObjectSizes(n) -} -\arguments{ -\item{n}{how many objects to list} -} -\value{ - -} -\description{ -Show the memory size of the top n objects -} -\examples{ -utils_printObjectSizes(10) -} diff --git a/man/utils_saveMeta.Rd b/man/utils_saveMeta.Rd deleted file mode 100644 index c52cac5..0000000 --- a/man/utils_saveMeta.Rd +++ /dev/null @@ -1,33 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{utils_saveMeta} -\alias{utils_saveMeta} -\title{Save file with metadata} -\usage{ -utils_saveMeta(savefnc = NULL, doPrint = F, path_log = NULL, ...) -} -\arguments{ -\item{savefnc}{a function to write some file to disk. If given as object is converted to character, default NULL} - -\item{doPrint}{print output to screen? useful if directin Rscript stdout to a log file (&>), default F} - -\item{path_log}{specify log file path; defaults to creating a file in current working dir, default NULL} - -\item{\dots}{named arguments to savefnc} -} -\value{ -None -} -\description{ -saves the following metadata -. filename (if savefnc is not NULL) or else -. current date and time -. sessionInfo() #sessioninfo::session_info() -. github log, if current or parent dir is a github dir -} -\examples{ -utils_saveMeta(savefnc=ggplot2::ggsave, doPrint=F, path_log = "~/log.txt", width=10) -TODO add pander pandoc markdown output option? -TODO add MD5SUM save -TODO add overwrite argument -} diff --git a/man/utils_verboseFnc.Rd b/man/utils_verboseFnc.Rd deleted file mode 100644 index e375409..0000000 --- a/man/utils_verboseFnc.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{utils_verboseFnc} -\alias{utils_verboseFnc} -\title{Wrapper to make a function more verbose} -\usage{ -utils_verboseFnc(fnc, ...) -} -\arguments{ -\item{fnc}{function to execute} - -\item{\dots}{named arguments to function} -} -\value{ -value returned by fnc -} -\description{ -Wrapper to make a function more verbose -} -\examples{ -utils_verboseFnc(rowSums, x=Matrix::Matrix(data=rnorm(9), nrow = r), na.rm = TRUE) -} From 3ab28b503e17c7ea2e4011deeb6a84a2d67d72d4 Mon Sep 17 00:00:00 2001 From: mauriziopaul Date: Tue, 18 Jul 2023 16:33:17 -0400 Subject: [PATCH 7/7] fixed issues so package can be built and installed --- DESCRIPTION | 3 ++- NAMESPACE | 21 +++++++++++++++++---- R/geneset_enrichment.R | 2 +- R/plot.R | 4 ++-- R/reduce_dimensions.R | 20 ++++++++++---------- R/remap.R | 2 +- SCOPfunctions.Rproj | 1 + man/dot-countsperclus.Rd | 3 --- man/estimate_dimensions.Rd | 24 ++++++++++++++++++++++++ man/f_VIF.Rd | 27 --------------------------- man/geneset_VIF.Rd | 17 +++++++++++++++-- man/plot_barIdentGroup.Rd | 28 +++++++++++++++++++++++++++- man/plot_network.Rd | 3 --- man/plot_vlnGrid.Rd | 26 +++++++++++++++++++++++++- man/remap.Rd | 19 ++++++++++++++++++- man/utils_big_as.matrix.Rd | 25 +++++++++++++++++++++++++ 16 files changed, 168 insertions(+), 57 deletions(-) create mode 100644 man/estimate_dimensions.Rd delete mode 100644 man/f_VIF.Rd create mode 100644 man/utils_big_as.matrix.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 52c4e46..ea92d0c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,6 +16,7 @@ Depends: Imports: Seurat, MAST, + Matrix, ggplot2, patchwork, parallel, @@ -23,4 +24,4 @@ Imports: utils, magrittr, methods -RoxygenNote: 7.1.1 +RoxygenNote: 7.2.3 diff --git a/NAMESPACE b/NAMESPACE index c204e62..a7d6480 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,4 +1,17 @@ -importFrom("grDevices", "colorRampPalette") - importFrom("methods", "is") - importFrom("stats", "aggregate", "as.formula", "cor", "p.adjust", - "pnorm", "quantile", "relevel", "sd") +# Generated by roxygen2: do not edit by hand + +export(.countsperclus) +export(DE_MAST_RE_seurat) +export(estimate_dimensions) +export(geneset_VIF) +export(geneset_embed) +export(geneset_embed_list_seurat) +export(plot_barIdentGroup) +export(plot_network) +export(plot_vlnGrid) +export(prep_HTO_q_area_plot) +export(prep_intrahash_doub) +export(prep_qc_rna) +export(remap) +export(utils_big_as.matrix) +importFrom(Matrix,rowSums) diff --git a/R/geneset_enrichment.R b/R/geneset_enrichment.R index 6be1080..41d77bf 100644 --- a/R/geneset_enrichment.R +++ b/R/geneset_enrichment.R @@ -11,7 +11,7 @@ #' #' @references modified from https://rdrr.io/bioc/qusage/src/R/qusage.R #' . drawing on https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3458527/ -#' @examples list_vec_VIF <- geneset_VIF(datExpr=mat_counts, list_genesets=mylist) +#' @examples ## list_vec_VIF <- geneset_VIF(datExpr=mat_counts, list_genesets=mylist) geneset_VIF <- function(datExpr, list_genesets) { list_vec_vif = lapply(names(list_genesets), function(genesetname) { vec_logicalgenes <-rownames(datExpr) %in% list_genesets[[genesetname]] diff --git a/R/plot.R b/R/plot.R index 0373ea8..83f4bb3 100644 --- a/R/plot.R +++ b/R/plot.R @@ -21,7 +21,7 @@ #' @return a ggplot2 object #' @export #' -#' @examples p <- plot_barIdentGroup(seurat_obj=seu, var_ident="sample",var_group="cluster") +#' @examples ##p <- plot_barIdentGroup(seurat_obj=seu, var_ident="sample",var_group="cluster") plot_barIdentGroup = function(seurat_obj, var_ident, var_group, @@ -106,7 +106,7 @@ plot_barIdentGroup = function(seurat_obj, #' @return ggplot2 object #' @export #' -#' @examples p <- plot_vlnGrid(seurat_obj=seu, assay="RNA", slot="data", var_group="cluster", vec_features=head(VariableFeatures(seu))) +#' @examples ##p <- plot_vlnGrid(seurat_obj=seu, assay="RNA", slot="data", var_group="cluster", vec_features=head(VariableFeatures(seu))) plot_vlnGrid = function(seurat_obj, assay, slot, diff --git a/R/reduce_dimensions.R b/R/reduce_dimensions.R index ab1b1a7..6739ba3 100644 --- a/R/reduce_dimensions.R +++ b/R/reduce_dimensions.R @@ -8,20 +8,20 @@ #' @return integer number of dimensions, <= max_dim #' @export #' -#' @examples estimate_dimensions(seurat_obj) -dim_red_est <- function(x, - max_dim=75, - seed.use=12345) { +#' @examples ##estimate_dimensions(seurat_obj) +estimate_dimensions <- function(x, + max_dim=75, + seed.use=12345) { - if(is(x, "SingleCellExperiment")) { - x <- as.Seurat(x) - } + if(is(x, "SingleCellExperiment")) { + x <- as.Seurat(x) + } - x %>% RunPCA(., npcs=max_dim, seed.use=seed.use, verbose = F) -> x + x %>% RunPCA(., npcs=max_dim, seed.use=seed.use, verbose = F) -> x - dims <- round(as.numeric(intrinsicDimension::maxLikGlobalDimEst(data = x@reductions$pca[, 1:max_dim], k = 20))) + dims <- round(as.numeric(intrinsicDimension::maxLikGlobalDimEst(data = x@reductions$pca[, 1:max_dim], k = 20))) - return(dims) + return(dims) } diff --git a/R/remap.R b/R/remap.R index 49dea9c..e283081 100644 --- a/R/remap.R +++ b/R/remap.R @@ -13,7 +13,7 @@ #' @return an object of the same format as dataIn with new gene names #' @export #' -#' @examples df_data_remapped = map_genes(dataIn=df_data, colRemap="genes", df_mapping=fread("./mapping/hgnc_ensembl.csv"), replace=T) +#' @examples ## df_data_remapped = remap(dataIn=df_data, colRemap="genes", df_mapping=fread("./mapping/hgnc_ensembl.csv"), replace=T) remap <- function(dataIn, colRemap = NULL, df_mapping, diff --git a/SCOPfunctions.Rproj b/SCOPfunctions.Rproj index 497f8bf..f0d6187 100644 --- a/SCOPfunctions.Rproj +++ b/SCOPfunctions.Rproj @@ -18,3 +18,4 @@ StripTrailingWhitespace: Yes BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace,vignette diff --git a/man/dot-countsperclus.Rd b/man/dot-countsperclus.Rd index b6df452..8baa3e0 100644 --- a/man/dot-countsperclus.Rd +++ b/man/dot-countsperclus.Rd @@ -12,9 +12,6 @@ \item{srt}{seurat object} \item{compare}{vector of groups you want to compare #add in} -} -\value{ - } \description{ subroutine diff --git a/man/estimate_dimensions.Rd b/man/estimate_dimensions.Rd new file mode 100644 index 0000000..3f5cae0 --- /dev/null +++ b/man/estimate_dimensions.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/reduce_dimensions.R +\name{estimate_dimensions} +\alias{estimate_dimensions} +\title{Estimate dataset dimensionality} +\usage{ +estimate_dimensions(x, max_dim = 75, seed.use = 12345) +} +\arguments{ +\item{x}{: Seurat or SingleCellExperiment object} + +\item{max_dim}{: max number of dimensions to try} + +\item{seed.use}{: random seed} +} +\value{ +integer number of dimensions, <= max_dim +} +\description{ +Estimate dataset dimensionality +} +\examples{ +##estimate_dimensions(seurat_obj) +} diff --git a/man/f_VIF.Rd b/man/f_VIF.Rd deleted file mode 100644 index e5c37b8..0000000 --- a/man/f_VIF.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/geneset_enrichment.R -\name{f_VIF} -\alias{f_VIF} -\title{Compute Variance Inflation Factors for gene sets} -\usage{ -f_VIF(datExpr, list_genesets) -} -\arguments{ -\item{datExpr}{gene * cell expression matrix with row and column names} - -\item{list_genesets}{list of genesets, using same gene names as datExpr} -} -\value{ -list of 2-vectors, one per geneset. First vector element is VIF, second is mean Pearson's rho correlation. -} -\description{ -Utility function to compute Variance Inflation Factors for gene sets using an expression dataset - in order to account for inter-gene correlation in gene sets derived from expression data -} -\examples{ -%list_vec_VIF <- f_VIF(datExpr=mat_counts, list_genesets=mylist) -} -\references{ -modified from https://rdrr.io/bioc/qusage/src/R/qusage.R -. drawing on https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3458527/ -} diff --git a/man/geneset_VIF.Rd b/man/geneset_VIF.Rd index 0242d14..bb0afd2 100644 --- a/man/geneset_VIF.Rd +++ b/man/geneset_VIF.Rd @@ -1,10 +1,12 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/geneset.R +% Please edit documentation in R/geneset.R, R/geneset_enrichment.R \name{geneset_VIF} \alias{geneset_VIF} \title{Compute Variance Inflation Factors for gene sets} \usage{ -geneset_VIF(datExpr, list_genesets, min_feats_present = 5) +geneset_VIF(datExpr, list_genesets) + +geneset_VIF(datExpr, list_genesets) } \arguments{ \item{datExpr}{gene * cell expression matrix with row and column names} @@ -14,13 +16,24 @@ geneset_VIF(datExpr, list_genesets, min_feats_present = 5) \item{min_feats_present}{a minimum number of features shared between mat_datExpr and vec_geneWeights} } \value{ +list of 2-vectors, one per geneset. First vector element is VIF, second is mean Pearson's rho correlation. + list of 2-vectors, one per geneset. First vector element is VIF, second is mean Pearson's rho correlation. } \description{ Utility function to compute Variance Inflation Factors for gene sets using an expression dataset in order to account for inter-gene correlation in gene sets derived from expression data + +Utility function to compute Variance Inflation Factors for gene sets using an expression dataset + in order to account for inter-gene correlation in gene sets derived from expression data +} +\examples{ +## list_vec_VIF <- geneset_VIF(datExpr=mat_counts, list_genesets=mylist) } \references{ +modified from https://rdrr.io/bioc/qusage/src/R/qusage.R +. drawing on https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3458527/ + modified from https://rdrr.io/bioc/qusage/src/R/qusage.R . drawing on https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3458527/ } diff --git a/man/plot_barIdentGroup.Rd b/man/plot_barIdentGroup.Rd index 7a6ca42..aa3a1ea 100644 --- a/man/plot_barIdentGroup.Rd +++ b/man/plot_barIdentGroup.Rd @@ -1,9 +1,27 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot_results.R +% Please edit documentation in R/plot.R, R/plot_results.R \name{plot_barIdentGroup} \alias{plot_barIdentGroup} \title{Generate barplot of identity group composition} \usage{ +plot_barIdentGroup( + seurat_obj, + var_ident, + var_group, + vec_group_colors = NULL, + f_color = colorRampPalette(brewer.pal(n = 11, name = "RdYlBu")), + do_plot = F, + title = NULL, + fontsize_title = 24, + fontsize_axistitle_x = 18, + fontsize_axistitle_y = 18, + fontsize_axistext_x = 12, + fontsize_axistext_y = 12, + fontsize_legendtitle = 12, + fontsize_legendtext = 10, + aspect.ratio = 1.2 +) + plot_barIdentGroup( seurat_obj, var_ident, @@ -54,9 +72,17 @@ plot_barIdentGroup( \item{aspect.ratio}{passed to ggplot2} } \value{ +a ggplot2 object + a ggplot2 object } \description{ Generate a percentage barplot that shows the composition of each identity (e.g. sample)in terms of groups (e.g. cell types) + +Generate a percentage barplot that shows the composition of each identity +(e.g. sample)in terms of groups (e.g. cell types) +} +\examples{ +##p <- plot_barIdentGroup(seurat_obj=seu, var_ident="sample",var_group="cluster") } diff --git a/man/plot_network.Rd b/man/plot_network.Rd index fdc6c4c..e4b3be0 100644 --- a/man/plot_network.Rd +++ b/man/plot_network.Rd @@ -31,9 +31,6 @@ plot_network( \item{color_edge}{color for network edges, character} \item{edge_thickness}{controls edge thickness, which varies by co-expression} -} -\value{ - } \description{ make a network plot of a set of co-expressed features diff --git a/man/plot_vlnGrid.Rd b/man/plot_vlnGrid.Rd index 0d4206b..c15318b 100644 --- a/man/plot_vlnGrid.Rd +++ b/man/plot_vlnGrid.Rd @@ -1,9 +1,26 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot_results.R +% Please edit documentation in R/plot.R, R/plot_results.R \name{plot_vlnGrid} \alias{plot_vlnGrid} \title{Make grid of violin plots} \usage{ +plot_vlnGrid( + seurat_obj, + assay, + slot, + var_group, + vec_features, + vec_group_colors = NULL, + f_color = colorRampPalette(brewer.pal(n = 11, name = "RdYlBu")), + flip = T, + do_plot = F, + pt.size = 0, + feature_fontface = "bold.italic", + fontsize_axistext_x = 12, + fontsize_axistext_y = 12, + aspect.ratio = NULL +) + plot_vlnGrid( seurat_obj, assay, @@ -49,8 +66,15 @@ plot_vlnGrid( \item{fontsize_axistext_y}{passed to ggplot2} } \value{ +ggplot2 object + ggplot2 object } \description{ produce a n_cluster * n_feature grid of violin plots + +produce a n_cluster * n_feature grid of violin plots +} +\examples{ +##p <- plot_vlnGrid(seurat_obj=seu, assay="RNA", slot="data", var_group="cluster", vec_features=head(VariableFeatures(seu))) } diff --git a/man/remap.Rd b/man/remap.Rd index bd85cf0..05b412f 100644 --- a/man/remap.Rd +++ b/man/remap.Rd @@ -1,9 +1,19 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R +% Please edit documentation in R/remap.R, R/utils.R \name{remap} \alias{remap} \title{Map dataframe column, vector, or list of vectors} \usage{ +remap( + dataIn, + colRemap = NULL, + df_mapping, + from = "hgnc", + to = "ensembl", + replace = F, + na.rm = T +) + remap( dataIn, colRemap = NULL, @@ -30,8 +40,15 @@ remap( \item{na.rm}{boolean; remove rows that fail to map or leave them as NAs?; defaults to TRUE} } \value{ +an object of the same format as dataIn with new gene names + an object of the same format as dataIn with new gene names } \description{ Use a user-provided look-up table, df_mapping, to map a vector. Handle NAs and collapse duplicates. + +Use a user-provided look-up table, df_mapping, to map a vector. Handle NAs and collapse duplicates. +} +\examples{ +## df_data_remapped = remap(dataIn=df_data, colRemap="genes", df_mapping=fread("./mapping/hgnc_ensembl.csv"), replace=T) } diff --git a/man/utils_big_as.matrix.Rd b/man/utils_big_as.matrix.Rd new file mode 100644 index 0000000..98a9c74 --- /dev/null +++ b/man/utils_big_as.matrix.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{utils_big_as.matrix} +\alias{utils_big_as.matrix} +\title{Convert a large sparse matrix into a dense matrix without errors} +\usage{ +utils_big_as.matrix(sparseMat, n_slices_init = 1, verbose = T) +} +\arguments{ +\item{sparseMat}{a big sparse matrix of a type coercible to dense Matrix::Matrix} + +\item{n_slices_init}{initial number of slices. Default value 1, i.e. whole matrix} + +\item{verbose}{print progress} +} +\value{ +a dense matrix +} +\description{ +Avoid the following error +. Error in asMethod(object) : +. Cholmod error 'problem too large' at file ../Core/cholmod_dense.c, +. by slicing the matrix into submatrices, converting and cbinding them +. Increases number of slices until they succeed. +}