Skip to contents

This function recursively expands a gating tree by adding child nodes according to gating rules. It is designed to iteratively apply gating decisions down to a specified depth or until no further subdivisions are applicable (terminal nodes).

Usage

recursiveAddChildNode(
  currentNode,
  root_data,
  sampledef,
  neg_gate,
  expr_group,
  ctrl_group,
  total_cell_per_file,
  maxDepth = 3,
  usedmarkers,
  min_cell_num = 25,
  depth = 1
)

Arguments

currentNode

The current node in the gating tree from which children will be generated.

root_data

A data frame containing the data set used for gating decisions.

sampledef

A data frame specifying sample definitions and group assignments.

neg_gate

A list containing thresholds for negative gating decisions.

expr_group

The name of the experimental group within `sampledef`.

ctrl_group

The name of the control group within `sampledef`.

total_cell_per_file

A data frame mapping file names to total cell counts, used for normalization.

maxDepth

The maximum depth to which the tree can expand.

usedmarkers

A vector of markers already used in the gating path up to the current node.

availableMarkers

A vector of markers that have not yet been used for gating at the current node.

Value

The modified current node with potentially new child nodes added, reflecting the gating tree expansion.

Details

The function checks if the current node is terminated or if its depth equals the maximum allowed depth. If not, it applies gating rules to decide how to expand the tree by adding child nodes. These decisions are based on statistical measures such as enrichment and entropy, calculated for different marker states. If a child node results in a terminal condition ('Leaf'), the tree expansion stops at that node.

The function uses recursion to navigate and expand deeper levels of the tree, ensuring that all potential gating paths are explored up to the `maxDepth` or until no further divisions are valid.

Examples

if (FALSE) { # \dontrun{
# Assuming currentNode and other required objects are predefined:
updatedNode <- recursiveAddChildNode(currentNode, root_data, 
availableMarkers, sampledef, neg_gate, expr_group,
ctrl_group, total_cell_per_file, maxDepth = 3, usedmarkers)
} # }