Skip to contents

This function tables a metadata column based on subtype classification.

Usage

get_subtype_metrics(
  this_metadata = NULL,
  this_metadata_variable = NULL,
  these_predictions = NULL,
  factor_level = NULL,
  subtype_class = "5_class"
)

Arguments

this_metadata

A data frame containing metadata with a sample_id column.

this_metadata_variable

A string specifying the column name in the metadata to be summarized.

these_predictions

A named vector of predictions with sample IDs as names.

factor_level

The level of the factor/value in this_metadata_variable to count (optional). If not provided, will return counts for all levels.

subtype_class

The classification system, default is 5 class.

Value

A data frame with the number of samples and counts for each subtype. If factor_level is specified, returns counts for that specific level. If factor_level is NULL, returns counts for all levels.

Details

The function performs the following steps:

  • Ensures the sample IDs are present in both metadata and predictions.

  • Checks if the desired metadata column is valid.

  • Filters metadata and predictions to include only common samples.

  • Combines metadata and predictions into a single data frame.

  • Counts the number of samples and occurrences of specified level for each subtype.

Examples

#run classifier
sjodahl_classes = classify_samples(this_data = sjodahl_2017, 
                                   log_transform = FALSE, 
                                   adjust = TRUE, 
                                   impute = TRUE, 
                                   include_data = TRUE, 
                                   verbose = FALSE)
              
#check progression events in each subtype                    
get_subtype_metrics(these_predictions = sjodahl_classes, 
                    this_metadata = sjodahl_2017_meta, 
                    this_metadata_variable = "surv_os_event", 
                    factor_level = 1)
#> # A tibble: 5 × 3
#>   prediction total_samples surv_os_event_1
#>   <chr>              <int>           <int>
#> 1 BaSq                  56              30
#> 2 GU                    54              29
#> 3 Mes                   16              11
#> 4 ScNE                  20               9
#> 5 Uro                  121              58

#check number of males in each subtype
get_subtype_metrics(these_predictions = sjodahl_classes, 
                    this_metadata = sjodahl_2017_meta, 
                    this_metadata_variable = "gender", 
                    factor_level = "Male")
#> # A tibble: 5 × 3
#>   prediction total_samples gender_Male
#>   <chr>              <int>       <int>
#> 1 BaSq                  56          41
#> 2 GU                    54          42
#> 3 Mes                   16          13
#> 4 ScNE                  20          14
#> 5 Uro                  121          95