calc_sumZscore: Calc_sumZscore

Description Usage Arguments Value Examples

View source: R/metrics.R

Description

Aggregate multiple integration metrics across multiple integration runs, ie from different batch correction algorithms, or different parameters for the same algorithms

Usage

1
calc_sumZscore(metric_df_list, batch_key)

Arguments

metric_df_list

a list of data.frames generated by applying run_all_metrics to multiple sets of integrations

batch_key

name of batch column in metadata used when generating run_all_metrics

Value

a vector of aggregated, z-scored metrics

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
library(scPOP)
data(sceiad_subset_data)

features <- sceiad_subset_data[, paste0('scviDim_', 1:8)]
metadata_1 <- sceiad_subset_data[,c('Barcode', 'cluster',  'subcluster',
                                  'batch', 'CellType', 'CellType_predict')]

## scramble example dataset to generate multiple integration runs
metadata_2 <- metadata_1
metadata_2$batch <- sample(metadata_2$batch, length(metadata_2$batch))
metadata_2$CellType_predict <- sample(metadata_2$CellType_predict,
                                   length(metadata_2$CellType_predict))
metadata_2$cluster <- sample(metadata_2$cluster, length(metadata_2$cluster))

metadata_3 <- metadata_1
metadata_3$batch <- sample(metadata_3$batch, length(metadata_3$batch))
metadata_3$CellType_predict <- sample(metadata_3$CellType_predict,
                                  length(metadata_3$CellType_predict))
metadata_3$cluster <- sample(metadata_3$cluster, length(metadata_3$cluster))
integration_data_list <- list( metadata_1, metadata_2, metadata_3)
metric_df_list <- lapply(integration_data_list, function(x)
                          run_all_metrics(reduction = features,
                          metadata = x,
                          batch_key = 'batch',
                          label1_key = 'CellType_predict',
                          label2_key = 'cluster',
                          run_name = 'example',
                          quietly =TRUE
                          )
                        )

 calc_sumZscore(metric_df_list,'batch' )
 

scPOP documentation built on Aug. 4, 2021, 5:06 p.m.