sample_statistics: Computes user specified functions on numerical columns and...

View source: R/analysis-functions.R

sample_statisticsR Documentation

Computes user specified functions on numerical columns and updates the metadata data frame accordingly.

Description

[Stable] The function operates on a data frame by grouping the content by the sample key and computing every function specified on every column in the value_columns parameter. After that the metadata data frame is updated by including the computed results as columns for the corresponding key. For this reason it's required that both x and metadata have the same sample key, and it's particularly important if the user is working with previously aggregated data. For example:

data("integration_matrices", package = "ISAnalytics")
data("association_file", package = "ISAnalytics")
aggreg <- aggregate_values_by_key(
 x = integration_matrices,
 association_file = association_file,
 value_cols = c("seqCount", "fragmentEstimate")
)
aggreg_meta <- aggregate_metadata(association_file = association_file)

sample_stats <- sample_statistics(x = aggreg,
metadata = aggreg_meta,
value_columns = c("seqCount", "fragmentEstimate"),
sample_key = c("SubjectID", "CellMarker","Tissue", "TimePoint"))

Usage

sample_statistics(
  x,
  metadata,
  sample_key = "CompleteAmplificationID",
  value_columns = "Value",
  functions = default_stats(),
  add_integrations_count = TRUE
)

Arguments

x

A data frame

metadata

The metadata data frame

sample_key

Character vector representing the key for identifying a sample

value_columns

The name of the columns to be computed, must be numeric or integer

functions

A named list of function or purrr-style lambdas

add_integrations_count

Add the count of distinct integration sites for each group? Can be computed only if x contains the mandatory columns mandatory_IS_vars()

Value

A list with modified x and metadata data frames

Required tags

The function will explicitly check for the presence of these tags:

  • All columns declared in mandatory_IS_vars()

These are checked only if add_integrations_count = TRUE.

See Also

Other Analysis functions: CIS_grubbs(), HSC_population_size_estimate(), compute_abundance(), cumulative_is(), gene_frequency_fisher(), is_sharing(), iss_source(), top_integrations(), top_targeted_genes()

Examples

data("integration_matrices", package = "ISAnalytics")
data("association_file", package = "ISAnalytics")
stats <- sample_statistics(
    x = integration_matrices,
    metadata = association_file,
    value_columns = c("seqCount", "fragmentEstimate")
)
stats

calabrialab/ISAnalytics documentation built on Nov. 2, 2023, 8:57 p.m.