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

Description Usage Arguments Value See Also Examples

View source: R/analysis-functions.R

Description

\lifecycle

experimental 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:

### Importing association file and matrices
path_AF <- system.file("extdata", "ex_association_file.tsv",
package = "ISAnalytics")
root_correct <- system.file("extdata", "fs.zip",
package = "ISAnalytics")
root_correct <- unzip_file_system(root_correct, "fs")

association_file <- import_association_file(path_AF, root_correct)
matrices <- import_parallel_Vispa2Matrices_auto(
association_file = association_file , root = NULL,
quantification_type = c("seqCount","fragmentEstimate"),
matrix_type = "annotated", workers = 2, patterns = NULL,
matching_opt = "ANY", dates_format = "dmy")

### Aggregating data (both by same key)
aggreggated_x <- aggregate_values_by_key(matrices$seqCount,
association_file)
aggregated_meta <- aggregate_metadata(association_file)

### Sample statistics
sample_stats <- sample_statistics(x = aggregated_x,
metadata = aggregated_meta,
sample_key = c("SubjectID", "CellMarker","Tissue", "TimePoint"))

Usage

1
2
3
4
5
6
7
sample_statistics(
  x,
  metadata,
  sample_key = "CompleteAmplificationID",
  value_columns = "Value",
  functions = default_stats()
)

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

Value

A list with modified x and metadata data frames

See Also

Other Analysis functions: CIS_grubbs(), comparison_matrix(), compute_abundance(), cumulative_count_union(), separate_quant_matrices(), threshold_filter(), top_integrations()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
op <- options(ISAnalytics.widgets = FALSE)

path_AF <- system.file("extdata", "ex_association_file.tsv",
    package = "ISAnalytics"
)
root_correct <- system.file("extdata", "fs.zip",
    package = "ISAnalytics"
)
root_correct <- unzip_file_system(root_correct, "fs")

association_file <- import_association_file(path_AF, root_correct,
    dates_format = "dmy"
)
matrices <- import_parallel_Vispa2Matrices_auto(
    association_file = association_file, root = NULL,
    quantification_type = c("seqCount", "fragmentEstimate"),
    matrix_type = "annotated", workers = 2, patterns = NULL,
    matching_opt = "ANY", multi_quant_matrix = FALSE
)

stats <- sample_statistics(matrices$seqCount, association_file)
options(op)

ISAnalytics documentation built on April 9, 2021, 6:01 p.m.