From 4ffca3b19f508b4edac10473876e4e2cfd1aa9de Mon Sep 17 00:00:00 2001 From: Kristen Wells Date: Mon, 12 Sep 2022 16:47:03 -0600 Subject: [PATCH 1/2] documenting with roxygen2 and adding data.table to dependencies --- DESCRIPTION | 5 +++-- man/dim_red_est.Rd | 24 ++++++++++++++++++++++++ man/dot-countsperclus.Rd | 3 --- 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_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 ---------------------- 15 files changed, 112 insertions(+), 182 deletions(-) create mode 100644 man/dim_red_est.Rd delete mode 100644 man/f_VIF.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/DESCRIPTION b/DESCRIPTION index 75b9b74..a3a2f3a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,14 +11,15 @@ LazyData: true Suggests: testthat (>= 3.0.0) Config/testthat/edition: 3 +Depends: + data.table Imports: Seurat, MAST, - data.table, ggplot2, patchwork, parallel, sessioninfo, utils, magrittr -RoxygenNote: 7.1.1 +RoxygenNote: 7.2.1.9000 diff --git a/man/dim_red_est.Rd b/man/dim_red_est.Rd new file mode 100644 index 0000000..8635586 --- /dev/null +++ b/man/dim_red_est.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/reduce_dimensions.R +\name{dim_red_est} +\alias{dim_red_est} +\title{Estimate dataset dimensionality} +\usage{ +dim_red_est(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/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/f_VIF.Rd b/man/f_VIF.Rd deleted file mode 100644 index 2e7613d..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..ae529df 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..0cf8221 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..6eea4a3 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..a9a7ccc 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 = map_genes(dataIn=df_data, colRemap="genes", df_mapping=fread("./mapping/hgnc_ensembl.csv"), replace=T) } 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 deea7a312e466741b58edb2ced62b0f44b1fe977 Mon Sep 17 00:00:00 2001 From: Kristen Wells Date: Mon, 12 Sep 2022 16:56:39 -0600 Subject: [PATCH 2/2] updating namespace --- NAMESPACE | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index d75f824..cf0655e 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)