Sugar function that extracts sequences from a source genome at the given
intervals and implants them into a target genome. Equivalent to calling
ggenome.implant with donor = source_genome and
genome_fasta = target_genome.
ggenome.transplant(
intervals,
source_genome,
target_genome = NULL,
output,
create_trackdb = TRUE,
trackdb_path = NULL,
line_width = 80L,
overwrite = FALSE
)A data.frame with chrom, start, end
columns specifying the regions to transplant.
Path to the misha database root containing the donor sequences.
Path to the target reference FASTA file. If
NULL, the current misha database is used.
Path for the output FASTA file.
Logical. If TRUE, creates a misha trackdb.
Path for the new trackdb.
Integer. Number of bases per FASTA line.
Logical. If TRUE, overwrite existing output.
Invisibly returns the output FASTA path.
gdb.init_examples()
# Create a "donor" DB with different sequence (all T's)
donor_fasta <- tempfile(fileext = ".fa")
cat(">chr1\n", paste(rep("T", 500000), collapse = ""), "\n",
">chr2\n", paste(rep("T", 300000), collapse = ""), "\n",
file = donor_fasta, sep = ""
)
donor_db <- tempfile()
gdb.create(donor_db, fasta = donor_fasta, verbose = FALSE)
# Export the current DB as the target FASTA
gdb.init_examples()
ref_fasta <- tempfile(fileext = ".fa")
gdb.export_fasta(ref_fasta)
# Transplant donor sequence into positions 100-200 of chr1
intervals <- data.frame(chrom = "chr1", start = 100, end = 200)
out <- tempfile(fileext = ".fa")
trackdb <- tempfile()
ggenome.transplant(intervals,
source_genome = donor_db,
target_genome = ref_fasta,
output = out,
create_trackdb = TRUE,
trackdb_path = trackdb
)
# Verify: positions 100-200 should now be all T's
gdb.init(trackdb)
gseq.extract(data.frame(chrom = "chr1", start = 100, end = 200))
#> [1] "TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT"
# Clean up
unlink(
c(
donor_fasta, donor_db, ref_fasta, out,
paste0(out, ".fai"), trackdb
),
recursive = TRUE
)