
Create a Physical Map from Chromosome and Position from Row Names
Source:R/extract_map.R
extract_map.RdThis function extracts chromosome and position information from the row names
of a genotype matrix. The row names are expected to follow a format
where components (for example chromosome, position) are separated by a symbol (e.g., "_", "-", ".").
The user can specify which part of the row name corresponds to the chromosome and position
using chrom_index and pos_index, and can customize the delimiter using split_symbol.
Usage
extract_map(
genotype_matrix,
chrom_index = 1,
pos_index = 2,
markers = FALSE,
split_symbol = "_"
)Arguments
- genotype_matrix
A matrix where:
Rows correspond to genetic markers.
Row names contain marker identifiers with multiple components separated by a delimiter (e.g.,
"A_1_200","B-2-300","C.3.400").Columns correspond to individuals (not used in the function but part of the input structure).
- chrom_index
Integer. The index of the chromosome identifier in the split row name. Default is
1(first element).- pos_index
Integer. The index of the position identifier in the split row name. Default is
2(second element).- markers
Logical. If
TRUE, includes original marker names from input in the output data frame. Default isFALSE.- split_symbol
Character. The delimiter used to split the row names. Default is
"_". Can be changed to"-",".", or other valid delimiters.
Value
A data frame with columns:
"chrom": Chromosome identifier extracted from row names."position": Numeric genomic position extracted from row names."marker"(optional): Marker names (ifmarkers = TRUE).
Details
Row names are split using the specified
split_symbolto extract chromosome and position.The user defines which components to extract using
chrom_indexandpos_index.Ensures the position column is numeric.
If
markers = TRUE, includes marker names in the output.
Examples
if (FALSE) { # \dontrun{
# Example genotype matrix with different delimiters
geno_matrix <- matrix(nrow = 3, ncol = 2)
rownames(geno_matrix) <- c("A_1_200", "B_2_300", "C_3_400")
# Default delimiter "_"
extract_map(geno_matrix)
# Using "-" as delimiter
rownames(geno_matrix) <- c("A-1-200", "B-2-300", "C-3-400")
extract_map(geno_matrix, chrom_index = 1, pos_index = 3, split_symbol = "-")
} # }