Af_metrics: Function to calculate metrics for each tree in an...

View source: R/Af_metrics.R

Af_metricsR Documentation

Function to calculate metrics for each tree in an AntibodyForests-object

Description

Function to calculate metrics for each tree in an AntibodyForests-object

Usage

Af_metrics(
  input,
  min.nodes,
  node.feature,
  group.node.feature,
  multiple.objects,
  metrics,
  parallel,
  num.cores,
  output.format
)

Arguments

input

AntibodyForests-object(s), output from Af_build()

min.nodes

The minimum number of nodes in a tree to calculate metrics (including the germline).

node.feature

The node feature to be used for the group.edge.length or group.nodes.depth metric.

group.node.feature

The groups in the node feature to be plotted. Set to NA if all features should displayed. (default NA)

multiple.objects

If TRUE: input should contain multiple AntibodyForests-objects (default FALSE)

metrics

The metrics to be calculated (default mean.depth and nr.nodes) 'nr.nodes' : The total number of nodes 'nr.cells' : The total number of cells in this clonotype 'mean.depth' : Mean of the number of edges connecting each node to the germline 'mean.edge.length' : Mean of the edge lengths between each node and the germline 'group.node.depth' : Mean of the number of edges connecting each node per group (node.features of the AntibodyForests-object) to the germline. (default FALSE) 'group.edge.length' : Mean of the sum of edge length of the shortest path between germline and nodes per group (node.features of the AntibodyForests-object) 'sackin.index' : Sum of the number of nodes between each terminal node and the germline, normalized by the total number of terminal nodes. 'spectral.density' : Metrics of the spectral density profiles (calculated with package RPANDA)

  • peakedness : Tree balance

  • asymmetry : Shallow or deep branching events

  • principal eigenvalue : Phylogenetic diversity

  • modalities : The number of different structures within the tree

parallel

If TRUE, the metric calculations are parallelized (default FALSE)

num.cores

Number of cores to be used when parallel = TRUE. (Defaults to all available cores - 1)

output.format

The format of the output. If set to "dataframe", a dataframe is returned. If set to "AntibodyForests", the metrics are added to the AntibodyForests-object. (default "dataframe")

Value

Returns either a dataframe where the rows are trees and the columns are metrics or an AntibodyForests-object with the metrics added to trees

Examples

metric_df <- Af_metrics(input = AntibodyForests::small_af,
                        metrics = c("mean.depth", "sackin.index"),
                        min.nodes = 8)
head(metric_df)

AntibodyForests documentation built on April 4, 2025, 4:45 a.m.