Skip to content

Commit

Permalink
Merge pull request #23 from spriyansh/main
Browse files Browse the repository at this point in the history
Updated Documentation
  • Loading branch information
spriyansh authored Dec 27, 2023
2 parents 7039c41 + f02323b commit c42942b
Show file tree
Hide file tree
Showing 40 changed files with 1,216 additions and 939 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/lint.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions R/DESeq2_estimateSizeFactorsForMatrix.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' @title estimateSizeFactorsForMatrix from DESeq2
#' @author Simon Anders
#' Please cite as
#' Love, M.I., Huber, W., Anders, S. Moderated estimation of fold change and dispersion for RNA-seq data with
#' DESeq2 Genome Biology 15(12):550 (2014)
#' Love, M.I., Huber, W., Anders, S. Moderated estimation of fold change and
#' dispersion for RNA-seq data with DESeq2 Genome Biology 15(12):550 (2014)
#'
#' Low-level function to estimate size factors with robust regression.
#'
Expand Down
21 changes: 10 additions & 11 deletions R/ScMaSigProClass.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' @slot bin_method A character string representing the algorithm used for
#' binning.
#' @slot path_col A character string representing the column name for branching
#' path assignment in 'Sparse' or 'Dense'data. See `colData` from the
#' path assignment in 'Sparse' or 'Dense' data. See `colData` from the
#' \pkg{SingleCellExperiment} package.
#' @slot bin_col A character string representing the name of the column in which
#' bin labels are stored.
Expand All @@ -32,7 +32,8 @@
#' metadata containing cell level annotations. (Default is "cell_type").
#' @slot g Update Description..
#' @slot p_value Significance Level.
#' @slot min_na Minimum values needed to estimate the model.
#' @slot min_na Minimum values needed per gene across cells to estimate the
#' model.
#' @slot mt_correction A character string specifying the p-value correction
#' method.
#' @slot epsilon Model convergence tolerance.
Expand All @@ -41,12 +42,13 @@
#' @slot offset A logical value specifying whether to use offset during fitting.
#' @slot log_offset A logical value specifying whether to take the logarithm of
#' the offsets.
#' @slot max_it Integer. Maximum number of iterations to fit the model.
#' @slot poly_degree Integer with the polynomial degree to fit the regression. 1
#' @slot distribution Distribution used
#' @slot cluster_method Description
#' @slot use_dim description
#' @slot fill_na description
#' @slot max_it Maximum number of iterations to fit the model.
#' @slot poly_degree Order of the polynomial linear model.
#' @slot distribution Distribution of the error term.
#' @slot cluster_method Clustering method used for clustering significant genes.
#' @slot use_dim Dimension to use for filling the missing values before
#' clustering.
#' @slot fill_na Method to fill the missing values.
#'
#' @name ParameterConfig
#' @aliases ParameterConfig-class
Expand Down Expand Up @@ -100,14 +102,11 @@ setClass(
}
}

# Check for slot g
if (!is.integer(object@g)) {
stop("Slot 'g' must be an integer.")
}

# Check for slot Q
if (!is.numeric(object@p_value)) {
stop("Slot 'p_value' must be numeric.")
}

if (!is.numeric(object@epsilon)) {
Expand Down
1 change: 1 addition & 0 deletions R/align_pseudotime.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#' @importFrom scales rescale
#' @importFrom S4Vectors DataFrame
#'
#' @param scmpObj description
#' @param ptime_col A character string representing the column name
#' for inferred Pseudotime values in 'Sparse' data. See `colData` from the
#' \pkg{SingleCellExperiment} package. (Default is "Pseudotime")
Expand Down
2 changes: 1 addition & 1 deletion R/create_scmp.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ create_scmp <- function(counts,
msg = paste("Rownames of raw-counts and cell-level-metadata are different.")
)

if (!is.null(bin_counts) | !is.null(bin_cell_data)) {
if (!is.null(bin_counts) || !is.null(bin_cell_data)) {
assert_that(nrow(bin_counts) == nrow(bin_cell_data),
msg = paste("Number of cells in bin_counts and bin_cell_data are different.")
)
Expand Down
4 changes: 2 additions & 2 deletions R/m3_select_path.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ m3_select_path <- function(cds,
inputType = "Monocle3",
ptime_col = ptime_col
)
} else if (plot_purity & !all(supplied_nodes %in% anno.df[["node"]])) {
} else if (plot_purity && !all(supplied_nodes %in% anno.df[["node"]])) {
# Tranfer data
data <- anno.df

Expand All @@ -213,7 +213,7 @@ m3_select_path <- function(cds,
group_by(!!sym(node), !!sym(anno)) %>%
summarise(count = n(), .groups = "drop")

data_summary <- data_summary[data_summary$count >= (mean(data_summary$count) + sd(data_summary$count)), ]
data_summary <- data_summary[data_summary[[count]] >= (mean(data_summary$count) + sd(data_summary[[count]])), ]

# Plotting the data
fraction_bar <- ggplot(data_summary, aes(x = .data$node, y = .data$count, fill = .data$anno)) +
Expand Down
22 changes: 11 additions & 11 deletions R/pb_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ optimize_bin_max <- function(bin_table, max_allowed, verbose = TRUE,
#' cell counts. It does this by either taking the mean or sum of counts across
#' cells in each bin, depending on the specified method.
#'
#' @param scmpObject object of Class scMaSigPro. See \code{\link{ScMaSigPro}}
#' @param scmpObj object of Class scMaSigPro. See \code{\link{ScMaSigPro}}
#' for more details.
#' @param bin_mem_col Column name in the Dense metadata storing information
#' about the members of the bins. (Default is 'scmp_bin_members').
Expand Down Expand Up @@ -502,29 +502,29 @@ optimize_bin_max <- function(bin_table, max_allowed, verbose = TRUE,
#'
#' @keywords internal

pb_counts <- function(scmpObject,
bin_mem_col = scmpObject@Parameters@bin_mem_col,
bin_col = scmpObject@Parameters@bin_col,
pb_counts <- function(scmpObj,
bin_mem_col = scmpObj@Parameters@bin_mem_col,
bin_col = scmpObj@Parameters@bin_col,
assay_name = "counts",
cluster_count_by = "sum") {
# Check Object Validity
assert_that(is(scmpObject, "ScMaSigPro"),
assert_that(is(scmpObj, "ScMaSigPro"),
msg = "Please provide object of class 'scMaSigPro'."
)

# Count slot
assert_that(
all(
assay_name %in% names(scmpObject@Sparse@assays@data@listData)
assay_name %in% names(scmpObj@Sparse@assays@data@listData)
),
msg = paste0("'", assay_name, "' ", "doesn't exit in scmpObject.")
msg = paste0("'", assay_name, "' ", "doesn't exit in scmpObj.")
)

# Get assay
counts <- scmpObject@Sparse@assays@data@listData[[assay_name]]
counts <- scmpObj@Sparse@assays@data@listData[[assay_name]]

# Get Pseudobulk Profile
pseudo_bulk_profile <- as.data.frame(colData(scmpObject@Dense))
pseudo_bulk_profile <- as.data.frame(colData(scmpObj@Dense))

assert_that(bin_mem_col %in% colnames(pseudo_bulk_profile),
msg = paste0("'", bin_mem_col, "' does not exist in level.meta.data")
Expand Down Expand Up @@ -567,8 +567,8 @@ pb_counts <- function(scmpObject,
colnames(pb.counts) <- meta.info[[bin_col]]

# Return the counts
scmpObject@Dense@assays@data@listData$bulk.counts <- as(pb.counts, "dgCMatrix")
scmpObj@Dense@assays@data@listData$bulk.counts <- as(pb.counts, "dgCMatrix")

# return
return(scmpObject)
return(scmpObj)
}
26 changes: 15 additions & 11 deletions R/plotBinTile.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#' @title Plot Bin Sizes Across Binned Time and Paths
#'
#' @description
#' This function generates plots to visualize the dense cell metadata from a ScMaSigPro
#' object. It produces tile plot to display the bin sizes across different
#' binned time intervals and paths.
#' This function generates plots to visualize the Dense slot cell metadata
#' from a ScMaSigPro object. It produces tile plot to display the bin sizes
#' across different binned time intervals and paths.
#'
#' @param scmpObj A ScMaSigPro class object with an additional slot 'Dense' that
#' contains compression information.
#' @param path_col Name of the column in `cell.metadata` storing information
#' for Path.
#' @param bin_size_col A title of the barplot
#' @param bin_ptime_col description
#' @param scmpObj An object of class \code{\link{ScMaSigPro}}.
#' @param path_col A character string representing the column name for branching
#' path assignment in 'Sparse' or 'Dense' slot.
#' @param bin_size_col A character string representing the name of the column in
#' which bin sizes per bin are stored. (Default is "scmp_bin_size").
#' @param bin_ptime_col A character string representing the column name
#' for binned Pseudotime values in 'Dense' data.
#' (Default is "scmp_binned_pseudotime").
#'
#' @return ggplot2 plot object.
#'
#' @author Priyansh Srivastava \email{spriyansh29@@gmail.com}
#'
#' @return A tile plot made with `geom_tile()`, visualizing the bin sizes across
#' different binned time and paths.
#' @export
plotBinTile <- function(scmpObj,
path_col = scmpObj@Parameters@path_col,
Expand Down
28 changes: 17 additions & 11 deletions R/plotIntersect.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
#' @title Generate UpSet Plot on Intersection of Significant Genes from scmpObject
#' @title Generate UpSet Plot
#'
#' @param scmpObj An object of class ScMaSigPro
#' @param min_intersection_size minimal number of observations in an intersection
#' @description
#' Generate UpSet Plot on Intersection of Significant Genes from scMaSigPro
#' object. It is a wrapper around `ComplexUpset::upset`.
#'
#' @importFrom S4Vectors isEmpty
#' @importFrom ComplexUpset upset intersection_matrix intersection_size upset_set_size
#' @importFrom RColorConesa colorConesa
#'
#' @param scmpObj An object of class \code{\link{ScMaSigPro}}.
#' @param min_intersection_size Minimal number of observations in an intersection
#' for it to be included.
#' @param width_ratio ratio of the overall set size width to intersection matrix
#' @param width_ratio Ratio of the overall set size width to intersection matrix
#' width.
#' @param keep_empty_groups whether empty sets should be kept (including sets
#' @param keep_empty_groups Whether empty sets should be kept (including sets
#' which are only empty after filtering by size)
#' @param show_sets_size the overall set sizes plot, e.g. from upset_set_size()
#' @param show_sets_size The overall set sizes plot, e.g. from upset_set_size()
#' (FALSE to hide)
#'
#' @return An UpSet plot visualizing the intersections of significant genes across pathways.
#' @importFrom S4Vectors isEmpty
#' @importFrom ComplexUpset upset intersection_matrix intersection_size upset_set_size
#' @importFrom RColorConesa colorConesa
#' @return ggplot2 plot object.
#'
#' @export
#' @author Priyansh Srivastava \email{spriyansh29@@gmail.com}
#'
#' @export
plotIntersect <- function(scmpObj, min_intersection_size = 2,
keep_empty_groups = TRUE,
width_ratio = 0.1, show_sets_size = FALSE) {
Expand Down
Loading

0 comments on commit c42942b

Please sign in to comment.