# First generating example MADC files
temp_dir <- tempdir()
file1_path <- file.path(temp_dir, "madc1.csv")
file2_path <- file.path(temp_dir, "madc2.csv")
out_path <- file.path(temp_dir, "merged_madc.csv")
# Data for file 1: Has SampleA and SampleB
df1 <- data.frame(
AlleleID = c("chr1.1_0001|Alt_0002", "chr1.1_0001|Ref_0001", "chr1.1_0001|AltMatch_0001"),
CloneID = c("chr1.1_0001", "chr1.1_0001", "chr1.1_0001"),
AlleleSequence = c("GGG", "AAA", "TTT"),
SampleA = c(10, 8, 0),
SampleB = c(5, 4, 9),
stringsAsFactors = FALSE,
check.names = FALSE
)
write.csv(df1, file1_path, row.names = FALSE, quote = FALSE)
# Data for file 2: Has SampleA (duplicate name) and SampleC, different rows
df2 <- data.frame(
AlleleID = c("chr1.1_0001|Alt_0002", "chr1.1_0001|Ref_0001", "chr1.1_0001|AltMatch_0001"),
CloneID = c("chr1.1_0001", "chr1.1_0001", "chr1.1_0001"),
AlleleSequence = c("GGG", "AAA", "TTT"),
SampleA = c(11, 7, 20),
SampleC = c(1, 2, 6),
stringsAsFactors = FALSE,
check.names = FALSE
)
write.csv(df2, file2_path, row.names = FALSE, quote = FALSE)
# 2. Run the merge function
# Use default suffixes (.x, .y) for the duplicated "SampleA"
merge_MADCs(madc_list = list(file1_path, file2_path),
out_madc = out_path)
Run the code above in your browser using DataLab