Extract Unique Genes from Gene Pairs Data Frame
Source:R/anglemanise_utils.R
extract_rows_for_unique_genes.Rd
Extracts unique gene identifiers from a data frame containing gene pairs and returns a vector of genes up to a specified maximum number.
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.
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"