This function merges a list of SNPDataLong objects, typically representing different SNP panels
or datasets, into a single unified SNPDataLong object. It ensures that all genotype matrices
have the same set of SNPs (filling missing SNPs with NA), and merges the marker map information while
removing duplicate SNP entries.
combineSNPData(lista)A single SNPDataLong object containing the combined genotype matrix, merged map,
and a concatenated path string.
# \donttest{
make_obj <- function(samples, snps) {
m <- methods::new("SnpMatrix",
matrix(as.raw(1:3),
nrow = length(samples),
ncol = length(snps),
dimnames = list(samples, snps)))
methods::new("SNPDataLong",
geno = m,
map = data.frame(Name = snps,
Chromosome = 1,
Position = seq_along(snps)),
path = tempfile(),
xref_path = "chip1")
}
obj1 <- make_obj(c("S1", "S2"), c("SNP1", "SNP2"))
#> Warning: data length [3] is not a sub-multiple or multiple of the number of rows [2]
obj2 <- make_obj(c("S3", "S4"), c("SNP2", "SNP3"))
#> Warning: data length [3] is not a sub-multiple or multiple of the number of rows [2]
combined <- combineSNPData(list(obj1, obj2))
#> Starting SNPDataLong combination...
#> Unified SNP panel with 3 SNPs.
#> Adding 1 missing SNPs filled with NA for one matrix...
#> object has no names - using numeric order for row/column names
#> Performing safe cbind on SnpMatrix objects...
#> Row and column names preserved after cbind.
#> Adding 1 missing SNPs filled with NA for one matrix...
#> object has no names - using numeric order for row/column names
#> Performing safe cbind on SnpMatrix objects...
#> Row and column names preserved after cbind.
#> Performing safe rbind on SnpMatrix objects...
#> Row and column names preserved after rbind.
#> Combination complete. Final matrix: 4 samples x 3 SNPs.
# }