Skip to contents

This function standardizes the column names of a genotype matrix by renaming parental genotypes (P1, P2), F1 individuals (F1.1, F1.2, ...), and F2 individuals (F2.1, F2.2, ...). This renaming helps reduce the name size and exchange it with a consistent labeling system for dendrogram visualization constrains

Usage

rename_geno_matrix(geno, parent1, parent2, f1)

Arguments

geno

A genotype matrix or data frame where:

  • Rows represent genetic markers.

  • Columns represent individuals (parents, F1, and F2).

parent1

Character. The column name corresponding to the first parent.

parent2

Character. The column name corresponding to the second parent.

f1

Character vector. The column names corresponding to F1 individuals.

Value

A genotype matrix with updated column names:

  • "P1" for parent1.

  • "P2" for parent2.

  • "F1.1", "F1.2", ... for F1 individuals.

  • "F2.1", "F2.2", ... for all other individuals.

Examples

# Example genotype matrix
geno_matrix <- matrix(sample(0:2, 30, replace = TRUE),
                      nrow = 5, ncol = 6,
                      dimnames = list(
                        paste0("Marker", 1:5),
                        c("ParentA-Plate1-WellAH", "ParentB-Plate2-WellAJ",
                        "F1abc", "F1bcd", "Ind1", "Ind2")
                      ))

# Rename genotype matrix
renamed_geno <- rename_geno_matrix(geno_matrix,
                                    parent1 = "ParentA",
                                    parent2 = "ParentB",
                                    f1 = c("F1abc", "F1bcd"))

# Print renamed genotype matrix
print(colnames(renamed_geno))
#> [1] "F2.1" "F2.2" "F1.1" "F1.2" "F2.3" "F2.4"