Skip to contents

Extracts unique gene identifiers from a data frame containing gene pairs and returns a vector of genes up to a specified maximum number.

Usage

extract_rows_for_unique_genes(dt, max_n_genes)

Arguments

dt

A data frame containing gene pairs, with columns geneA and geneB.

max_n_genes

An integer specifying the maximum number of unique genes to return.

Value

A vector of unique gene identifiers.

Details

The function combines the geneA and geneB columns, extracts unique gene names, and returns the first max_n_genes genes. If max_n_genes exceeds the number of unique genes available, all unique genes are returned.

See also

Examples

gene_pairs <- data.frame(
  geneA = c("Gene1", "Gene2", "Gene3", "Gene4"),
  geneB = c("Gene3", "Gene4", "Gene5", "Gene6")
)
unique_genes <- extract_rows_for_unique_genes(
  gene_pairs,
  max_n_genes = 3
)
print(unique_genes)
#> [1] "Gene1" "Gene3" "Gene2"