Description Usage Arguments Details Value Examples
Uniformly downsample a vector of non-negative integers to have a specified sum. That is, keep randomly subtracting 1 from nonzero elements of the vector until it has the desired sum. Each count is equally likely to be taken. That is, an element with value 8 is 4 times more likely to be decremented than an element with value 2.
1 2 3 4 5 6 7 | downsample_count_vec(vec, end_sum)
downsample_count_mat_rows(mat, end_sum)
downsample_count_mat_cols(mat, end_sum)
downsample_gene_counts(df, end_sum)
|
vec |
A vector of non-negative integers. |
end_sum |
The number that you would like vector to sum to after downsampling. This must be less than the initial sum. |
mat |
A matrix of non-negative integers. |
df |
A data frame with gene names as columns. |
downsample_count_mat_rows()
and downsample_count_mat_cols()
just do
downsample_vec()
to all rows and columns of a matrix using apply()
.
downsample_gene_counts()
downsamples on the subset of columns in the
data frame that have names in get_gene_names()
.
If end_sum > sum(vec)
, vec
is returned unchanged.
A vector of non-negative integers.
1 2 3 4 5 6 7 8 | downsample_count_vec(1:24, 24)
mat <- matrix(sample.int(100, size = 6^2, replace = TRUE), nrow = 6)
downsample_count_mat_rows(mat, end_sum = 6)
downsample_count_mat_cols(mat, end_sum = 6)
if (rlang::is_installed("mirmodels")) {
ms_data <- mirmodels::get_ms_data(gene_predicate = ~ median(.) > 0)
downsampled_ms <- downsample_gene_counts(ms_data, end_sum = 1e6)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.