knee_plot: Plot the transposed knee plot and inflection point

Description Usage Arguments Value Note Examples

View source: R/knee_plot.R

Description

Plot a transposed knee plot, showing the inflection point and the number of remaining cells after inflection point filtering. It's transposed since it's more generalizable to multi-modal data.

Usage

1
2
3
4
5
get_knee_df(mat)

get_inflection(df, lower = 100)

knee_plot(df, inflection)

Arguments

mat

Gene count matrix, a dgCMatrix.

df

The data frame from get_knee_df.

lower

Minimum total UMI counts for barcode for it to be considered when calculating the inflection point; this helps to avoid the noisy part of the curve for barcodes with very few counts.

inflection

Output of get_inflection.

Value

get_knee_df returns a tibble with two columns: total for total UMI counts for each barcode, and rank for rank of the total counts, with number 1 for the barcode with the most counts.

get_inflection returns a numeric(1) for the total UMI count at the inflection point.

knee_plot returns a ggplot2 object.

Note

Code in part adapted from barcodeRanks from DropetUtils.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Download dataset already in BUS format
library(TENxBUSData)
TENxBUSData(".", dataset = "hgmm100")
tr2g <- transcript2gene(c("Homo sapiens", "Mus musculus"), 
  type = "vertebrate",
  ensembl_version = 99, kallisto_out_path = "./out_hgmm100")
m <- make_sparse_matrix("./out_hgmm100/output.sorted.txt",
  tr2g = tr2g, est_ncells = 1e5,
  est_ngenes = nrow(tr2g), TCC = FALSE)
df <- get_knee_df(m)
infl <- get_inflection(df)
knee_plot(df, infl)

BUSpaRse documentation built on March 3, 2021, 2:01 a.m.