make_igv_snapshot.Rd
Load bams and generate an IGV screenshot for one or more regions.
make_igv_snapshot(
bams,
these_sample_ids,
this_seq_type = "genome",
genome_build,
region,
padding = 200,
chrom,
start,
end,
out_path = "/tmp/",
igv_port = 60506,
socket,
gene = "NA",
details = "",
clobber = FALSE,
sort_by = "base",
colour_by,
squish = FALSE,
viewaspairs = FALSE
)
Character vector containing the full path to one or more bam files (specify if not providing these_sample_ids)
A vector of one or more sample_id (bams for these samples will be auto-loaded)
TO DO: automatically obtain this for the user from the metadata
String specifying the genome build for the bam files provided (TO DO: if it isn't already, it should be determined automatically if these_sample_ids was provided).
Optionally specify the region as a single string (e.g. "chr1:1234-1235").
Optionally specify a positive value to broaden the region around the specified position. Default is 200.
Optionally specify the region by specifying the chromosome, start and end (see below).
Optionally specify the region by specifying the start.
Optionally specify the region by specifying the end.
Specify the output directory where the snapshot will be written.
Specify the port IGV is listening on. Default: 60506 (optional if using the default).
Provide the socket variable obtained by running this function with no arguments
Optionally provide a gene name that will be incorporated into the output file name
Optionally provide any other text you want incorporated into the output file name
Force existing file to be clobbered?
Specify whether and how to sort the reads (e.g. "base"; see IGV documentation)
Specify how IGV should colour the reads (see IGV documentation)
Force reads to be squished (see IGV documentation)
Set to TRUE if you want the reads to be shown as pairs rather than independently (see IGV documentation)
Path to file (.png).
Specify the path to one or more bam files as a character vector to the bams
parameter.
The user can also specify regions of interest with either the region
parameter (chr:start-end),
or the user can directly supply the chromosome, start and end coordinates with the chrom
, start
, and end
parameters.
For more information and examples, refer to the function examples and parameter descriptions.
IMPORTANT: you must be running IGV on the host that is running R and you need to have it listening on a port.
The simplest scenario is to run this command on a terminal (if using a Mac),
assuming you are using R on gphost10 and you have a ssh config that routes gp10 to that host
-X gp10 ssh
then launch IGV (e.e. from a conda installation):
& conda activate igv; igv
if (FALSE) {
this_sv = annotated_sv %>%
filter(gene=="ETV6")
#you don't need to know the details for the bam file but you can supply it if you want
tumour_bam = get_bams(sample = this_sv$tumour_sample_id)
#run with no arguments to get the socket for a running IGV instance
socket = make_igv_snapshot()
make_igv_snapshot(chrom = this_sv$chrom2,
start = this_sv$start2,
end = this_sv$end2,
this_sample_id = this_sv$tumour_sample_id,
out_path = "~/IGV_snapshots/")
this_mutation = get_coding_ssm(seq_type="capture") %>%
head(1)
make_igv_snapshot(socket = socket,
sample_ids = this_mutation$Tumor_Sample_Barcode,
this_seq_type = "capture",
colour_by = "READ_STRAND")
#run on a bunch of variants using apply:
apply(to_snapshot,1,function(x){
make_igv_snapshot(sample_ids = x["sample_id"],
seq_type_filter = "capture",
chrom = x["chr"],
start = x["start"],
end = x["end"],
details = paste0(x["ref"],"-",x["alt"]),
gene = x["Hugo_Symbol"],
socket = socket)})
}