diff --git a/R/multi_gene_pca.R b/R/multi_gene_pca.R index 403ff2b3..6a4521ba 100644 --- a/R/multi_gene_pca.R +++ b/R/multi_gene_pca.R @@ -16,7 +16,7 @@ #' @author Nicholas J. Eagles #' @importFrom stats prcomp #' @family functions for summarizing expression of multiple continuous variables simultaneously -multi_gene_z_score <- function(cont_mat) { +multi_gene_pca <- function(cont_mat) { pc_exp <- stats::prcomp(cont_mat, center = TRUE, scale = TRUE) pc_vec <- pc_exp$x[, "PC1"] diff --git a/R/multi_gene_sparsity.R b/R/multi_gene_sparsity.R index 037254c0..0ae47e19 100644 --- a/R/multi_gene_sparsity.R +++ b/R/multi_gene_sparsity.R @@ -12,6 +12,6 @@ #' @author Nicholas J. Eagles #' @import MatrixGenerics #' @family functions for summarizing expression of multiple continuous variables simultaneously -multi_gene_z_score <- function(cont_mat) { +multi_gene_sparsity <- function(cont_mat) { return(rowMeans(cont_mat > 0)) } diff --git a/man/multi_gene_pca.Rd b/man/multi_gene_pca.Rd new file mode 100644 index 00000000..364394c6 --- /dev/null +++ b/man/multi_gene_pca.Rd @@ -0,0 +1,33 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/multi_gene_pca.R +\name{multi_gene_pca} +\alias{multi_gene_pca} +\title{Combine multiple continuous variables through PCA} +\usage{ +multi_gene_pca(cont_mat) +} +\arguments{ +\item{cont_mat}{A \code{matrix()} with spots as rows and 2 or more continuous +variables as columns.} +} +\value{ +A \code{numeric()} vector with one element per spot, summarizing the +multiple continuous variables. +} +\description{ +PCA is performed on \code{cont_mat}, the matrix of multiple continuous +features. The first PC is returned, representing the dominant spatial +signature of the feature set. Its direction is negated if necessary so that +the majority of coefficients across features are positive (when the features +are highly correlated, this encourages spots with higher values to +represent areas of higher expression of the features). +} +\seealso{ +Other functions for summarizing expression of multiple continuous variables simultaneously: +\code{\link{multi_gene_sparsity}()}, +\code{\link{multi_gene_z_score}()} +} +\author{ +Nicholas J. Eagles +} +\concept{functions for summarizing expression of multiple continuous variables simultaneously} diff --git a/man/multi_gene_sparsity.Rd b/man/multi_gene_sparsity.Rd new file mode 100644 index 00000000..31ca2a0b --- /dev/null +++ b/man/multi_gene_sparsity.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/multi_gene_sparsity.R +\name{multi_gene_sparsity} +\alias{multi_gene_sparsity} +\title{Combine multiple continuous variables by proportion of positive values} +\usage{ +multi_gene_sparsity(cont_mat) +} +\arguments{ +\item{cont_mat}{A \code{matrix()} with spots as rows and 2 or more continuous +variables as columns.} +} +\value{ +A \code{numeric()} vector with one element per spot, summarizing the +multiple continuous variables. +} +\description{ +To summarize multiple features, the proportion of features with positive +values for each spot is computed. +} +\seealso{ +Other functions for summarizing expression of multiple continuous variables simultaneously: +\code{\link{multi_gene_pca}()}, +\code{\link{multi_gene_z_score}()} +} +\author{ +Nicholas J. Eagles +} +\concept{functions for summarizing expression of multiple continuous variables simultaneously} diff --git a/man/multi_gene_z_score.Rd b/man/multi_gene_z_score.Rd index 8c94a369..6869e53d 100644 --- a/man/multi_gene_z_score.Rd +++ b/man/multi_gene_z_score.Rd @@ -1,14 +1,9 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/multi_gene_pca.R, R/multi_gene_sparsity.R, -% R/multi_gene_z_score.R +% Please edit documentation in R/multi_gene_z_score.R \name{multi_gene_z_score} \alias{multi_gene_z_score} -\title{Combine multiple continuous variables through PCA} +\title{Combine multiple continuous variables by averaging Z scores} \usage{ -multi_gene_z_score(cont_mat) - -multi_gene_z_score(cont_mat) - multi_gene_z_score(cont_mat) } \arguments{ @@ -16,29 +11,18 @@ multi_gene_z_score(cont_mat) variables as columns.} } \value{ -A \code{numeric()} vector with one element per spot, summarizing the -multiple continuous variables. - -A \code{numeric()} vector with one element per spot, summarizing the -multiple continuous variables. - A \code{numeric()} vector with one element per spot, summarizing the multiple continuous variables. } \description{ -PCA is performed on \code{cont_mat}, the matrix of multiple continuous -features. The first PC is returned, representing the dominant spatial -signature of the feature set. Its direction is negated if necessary so that -the majority of coefficients across features are positive (when the features -are highly correlated, this encourages spots with higher values to -represent areas of higher expression of the features). - -To summarize multiple features, the proportion of features with positive -values for each spot is computed. - To summarize multiple features, each is normalized to represent a Z-score. Scores are averaged to return a single vector. } +\seealso{ +Other functions for summarizing expression of multiple continuous variables simultaneously: +\code{\link{multi_gene_pca}()}, +\code{\link{multi_gene_sparsity}()} +} \author{ Nicholas J. Eagles }