Make multiple Locus Zoom plots
This is a general guide and recommendation on how to make multiple Locus Zooms.
Loop the locus.zoom() call
Probably the best way to make multiple Locus Zoom plots is to loop the function call to locus.zoom()
.
Inputs that change between different Locus Zoom plots are:
- SNP of interest/Gene of interest/Region of interest
- LD information of the region
Since the LD can be calculated on-the-fly, if you have a vector of SNPs/genes/regions of interest, you will be able to create a simple loop like so:
|
|
Note here that the secondary.snp
option has been set to the vector of variants of interest, and the ignore.lead
option has been enabled. By passing the vector of interest to the secondary.snp
option, it allows locus.zoom()
to plot any SNPs of interest within the region of the plot, as well as the SNPs you are interested in.
In order to make sure the SNP of interest is colored correctly based on its LD, the ignore.lead
option has been set. If this option wasn’t set, then the LD information of the top SNP in that region would always be used instead of the LD information of the SNP of interest that you wanted.
For regions of interest, we recommend you put the regions into a data frame with the following columns and pass each row to the function with a similar loop as above:
Options | Description |
---|---|
chr |
Chromosome |
start |
Start position of region |
end |
End position of region |
LD calculation – on-the-fly, or pre-calculated?
One thing to consider when generating multiple Locus Zoom plots is how you want to pass the LD information to the function.
In most cases, on-the-fly LD calculation will work. However, when your SNP of interest is not present in the reference data, there is no way to calculate the LD between the SNP of interest with all other variants in the region.
Potential work around for this are:
- Use a different reference data for LD calculation
- Use a different (surrogate) marker’s LD information
Either way, unless you edit the locus.zoom()
function yourself, you will have to calculate your own LD in order to work around this problem.
Manually including LD information
One method is to generate the LDs of all of the SNPs of interest beforehand, load it all into a list
, and loop through this list together with the locus.zoom()
function.
Calculate LD information
The following code will generate LD for all the variants from a plink
loci file in parallel:
|
|
First four columns of plink
loci file are:
Column name | Description |
---|---|
CHR |
Chromosome |
F |
File number (ignored in the script) |
SNP |
rsID |
BP |
Base position of the SNP |
This file doesn’t have to come directly from plink
– you can make your own loci file and pass it to the above script to generate your own LD.
Modify the loop
Modify the loop as below:
|
|
Now, the above code assumes the LD files are named <rsid>.ld
, so if you have made a different LD using a surrogate SNP, then rename the surrogate SNP LD file so it matches up with the rsID of the SNP of interest.