├── src ├── .gitignore ├── RcppExports.cpp └── GT_to_SnpMatrix.cpp ├── demo ├── 00Index └── LDheatmap.R ├── docs ├── logo.png ├── reference │ ├── GIMAP5-1.png │ ├── CHBJPTData-1.png │ ├── GIMAP5.CEU-1.png │ ├── GIMAP5CEU-1.png │ ├── LDheatmap-1.png │ ├── LDheatmap-10.png │ ├── LDheatmap-11.png │ ├── LDheatmap-12.png │ ├── LDheatmap-13.png │ ├── LDheatmap-14.png │ ├── LDheatmap-15.png │ ├── LDheatmap-16.png │ ├── LDheatmap-17.png │ ├── LDheatmap-2.png │ ├── LDheatmap-3.png │ ├── LDheatmap-4.png │ ├── LDheatmap-5.png │ ├── LDheatmap-6.png │ ├── LDheatmap-7.png │ ├── LDheatmap-8.png │ ├── LDheatmap-9.png │ ├── figures │ │ └── logo.png │ ├── LDheatmap.marks-1.png │ ├── LDheatmap.addGrob-1.png │ ├── LDheatmap.addGrob-2.png │ ├── LDheatmap.highlight-1.png │ ├── LDheatmap.addScatterplot-1.png │ ├── LDheatmap.addScatterplot-2.png │ ├── LDheatmap-internal.html │ ├── GIMAP5CEU.html │ ├── CEUData.html │ ├── LDheatmap.addGrob.html │ ├── index.html │ └── recombRate.html ├── articles │ ├── vcfOnLDheatmap_files │ │ └── figure-html │ │ │ ├── unnamed-chunk-3-1.png │ │ │ └── unnamed-chunk-3-2.png │ └── index.html ├── pkgdown.yml ├── link.svg ├── sitemap.xml ├── docsearch.js ├── jquery.sticky-kit.min.js ├── pkgdown.js ├── pkgdown.css ├── authors.html └── index.html ├── data ├── CEUDist.rda ├── CEUSNP.rda ├── CHBJPTSNP.rda ├── GIMAP5.RData ├── CHBJPTDist.rda └── GIMAP5.CEU.RData ├── R ├── import.R ├── RcppExports.R ├── LDheatmap-package.R ├── LDheatmap-internal.R ├── LDheatmap.moveGenemap.R ├── CEUDataRd.R ├── GIMAP5CEUrd.R ├── CHBJPTDataRd.R ├── GIMAP5Rd.R ├── LDheatmap.addGrob.R ├── LDheatmap.addRecombRate.R ├── LDheatmap.addGenes.R ├── vcfR2SnpMatrix.R ├── LDheatmap.marks.R ├── LDheatmap.addScatterplot.R ├── utils.R ├── recombRate.R └── LDheatmapHelpers.R ├── man ├── figures │ └── logo.png ├── LDheatmap-internal.Rd ├── LDheatmap.addGrob.Rd ├── CEUSNP.Rd ├── recombRate.Rd ├── LDheatmap.addRecombRate.Rd ├── plotGenes.Rd ├── CHBJPTSNP.Rd ├── GIMAP5.CEU.Rd ├── LDheatmap.addGenes.Rd ├── vcfR2SnpMatrix.Rd ├── GIMAP5.Rd ├── LDheatmap.addScatterplot.Rd ├── LDheatmap.marks.Rd └── LDheatmap.highlight.Rd ├── vignettes ├── gTree.pdf ├── jsslogo.jpg ├── snp_in_vcf.vcf ├── vcfOnLDheatmap.Rmd └── LDheatmap.bib ├── .Rbuildignore ├── data-raw ├── CEUData.R ├── CHBJPTData.R └── hapmapCEU.txt ├── NAMESPACE ├── _pkgdown.yaml ├── inst ├── CITATION └── ChangeLog ├── README.Rmd └── DESCRIPTION /src/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.so 3 | *.dll 4 | -------------------------------------------------------------------------------- /demo/00Index: -------------------------------------------------------------------------------- 1 | LDheatmap demo for drawing an LD heatmap 2 | -------------------------------------------------------------------------------- /docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/logo.png -------------------------------------------------------------------------------- /data/CEUDist.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/data/CEUDist.rda -------------------------------------------------------------------------------- /data/CEUSNP.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/data/CEUSNP.rda -------------------------------------------------------------------------------- /R/import.R: -------------------------------------------------------------------------------- 1 | #' @import grid 2 | #'@importFrom grDevices grey.colors rainbow rgb 3 | NULL 4 | -------------------------------------------------------------------------------- /data/CHBJPTSNP.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/data/CHBJPTSNP.rda -------------------------------------------------------------------------------- /data/GIMAP5.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/data/GIMAP5.RData -------------------------------------------------------------------------------- /data/CHBJPTDist.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/data/CHBJPTDist.rda -------------------------------------------------------------------------------- /data/GIMAP5.CEU.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/data/GIMAP5.CEU.RData -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/man/figures/logo.png -------------------------------------------------------------------------------- /vignettes/gTree.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/vignettes/gTree.pdf -------------------------------------------------------------------------------- /vignettes/jsslogo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/vignettes/jsslogo.jpg -------------------------------------------------------------------------------- /vignettes/snp_in_vcf.vcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/vignettes/snp_in_vcf.vcf -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^docs$ 4 | ^_pkgdown\.yaml$ 5 | ^Rplots\.pdf$ 6 | ^README\.Rmd$ -------------------------------------------------------------------------------- /docs/reference/GIMAP5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/GIMAP5-1.png -------------------------------------------------------------------------------- /docs/reference/CHBJPTData-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/CHBJPTData-1.png -------------------------------------------------------------------------------- /docs/reference/GIMAP5.CEU-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/GIMAP5.CEU-1.png -------------------------------------------------------------------------------- /docs/reference/GIMAP5CEU-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/GIMAP5CEU-1.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-1.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-10.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-11.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-12.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-13.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-14.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-15.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-16.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-17.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-2.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-3.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-4.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-5.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-6.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-7.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-8.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap-9.png -------------------------------------------------------------------------------- /docs/reference/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/figures/logo.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap.marks-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap.marks-1.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap.addGrob-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap.addGrob-1.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap.addGrob-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap.addGrob-2.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap.highlight-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap.highlight-1.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap.addScatterplot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap.addScatterplot-1.png -------------------------------------------------------------------------------- /docs/reference/LDheatmap.addScatterplot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/reference/LDheatmap.addScatterplot-2.png -------------------------------------------------------------------------------- /docs/articles/vcfOnLDheatmap_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/articles/vcfOnLDheatmap_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/articles/vcfOnLDheatmap_files/figure-html/unnamed-chunk-3-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SFUStatgen/LDheatmap/HEAD/docs/articles/vcfOnLDheatmap_files/figure-html/unnamed-chunk-3-2.png -------------------------------------------------------------------------------- /R/RcppExports.R: -------------------------------------------------------------------------------- 1 | # Generated by using Rcpp::compileAttributes() -> do not edit by hand 2 | # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 3 | 4 | GT_to_SnpMatrix <- function(GT, phased = TRUE) { 5 | .Call(`_LDheatmap_GT_to_SnpMatrix`, GT, phased) 6 | } 7 | 8 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: 1.19.2.1 2 | pkgdown: 1.1.0 3 | pkgdown_sha: ~ 4 | articles: 5 | vcfOnLDheatmap: vcfOnLDheatmap.html 6 | urls: 7 | reference: https://github.com/mcneney/LDheatmap/reference 8 | article: https://github.com/mcneney/LDheatmap/articles 9 | 10 | -------------------------------------------------------------------------------- /R/LDheatmap-package.R: -------------------------------------------------------------------------------- 1 | ## usethis namespace: start 2 | #' @importFrom Rcpp sourceCpp 3 | #' @useDynLib LDheatmap, .registration = TRUE 4 | #' @export preDrawDetails.ldheatmap 5 | #' @export postDrawDetails.ldheatmap 6 | #' @export preDrawDetails.symbols 7 | #' @export postDrawDetails.symbols 8 | ## usethis namespace: end 9 | NULL 10 | -------------------------------------------------------------------------------- /data-raw/CEUData.R: -------------------------------------------------------------------------------- 1 | CEUData<-utils::read.table("hapmapCEU.txt", header=TRUE) 2 | CEUSNP <- CEUData[-1,] 3 | for (LDindex in 1:length(CEUSNP)) 4 | CEUSNP[,LDindex] <- genetics::as.genotype(CEUSNP[,LDindex]) 5 | CEUDist<- as.vector(as.matrix(CEUData[1,]), mode="numeric") 6 | rm(LDindex, CEUData) 7 | usethis::use_data(CEUSNP,CEUDist, overwrite = TRUE) -------------------------------------------------------------------------------- /R/LDheatmap-internal.R: -------------------------------------------------------------------------------- 1 | #' @name LDheatmap-internal 2 | #' @title Internal LDheatmap functions and data files 3 | #' @aliases preDrawDetails.ldheatmap 4 | #' postDrawDetails.ldheatmap 5 | #' preDrawDetails.symbols 6 | #' postDrawDetails.symbols 7 | #' constructVP 8 | #' drawLDheatmapGrob 9 | #' moveTitles 10 | #' @description Internal LDheatmap functions. 11 | #' @details These are not to be called by the user or are undocumented. 12 | #' @keywords internal 13 | NULL -------------------------------------------------------------------------------- /man/LDheatmap-internal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/LDheatmap-internal.R 3 | \name{LDheatmap-internal} 4 | \alias{LDheatmap-internal} 5 | \alias{preDrawDetails.ldheatmap} 6 | \alias{postDrawDetails.ldheatmap} 7 | \alias{preDrawDetails.symbols} 8 | \alias{postDrawDetails.symbols} 9 | \alias{constructVP} 10 | \alias{drawLDheatmapGrob} 11 | \alias{moveTitles} 12 | \title{Internal LDheatmap functions and data files} 13 | \description{ 14 | Internal LDheatmap functions. 15 | } 16 | \details{ 17 | These are not to be called by the user or are undocumented. 18 | } 19 | \keyword{internal} 20 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(LDheatmap) 4 | export(LDheatmap.addGenes) 5 | export(LDheatmap.addGrob) 6 | export(LDheatmap.addRecombRate) 7 | export(LDheatmap.addScatterplot) 8 | export(LDheatmap.highlight) 9 | export(LDheatmap.marks) 10 | export(plotGenes) 11 | export(postDrawDetails.ldheatmap) 12 | export(postDrawDetails.symbols) 13 | export(preDrawDetails.ldheatmap) 14 | export(preDrawDetails.symbols) 15 | export(recombRate) 16 | export(vcfR2SnpMatrix) 17 | import(grid) 18 | importFrom(Rcpp,sourceCpp) 19 | importFrom(grDevices,grey.colors) 20 | importFrom(grDevices,rainbow) 21 | importFrom(grDevices,rgb) 22 | useDynLib(LDheatmap, .registration = TRUE) 23 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /_pkgdown.yaml: -------------------------------------------------------------------------------- 1 | title: LDheatmap 2 | url: https://github.com/mcneney/LDheatmap 3 | template: 4 | params: 5 | bootswatch: flatly 6 | navbar: 7 | left: 8 | - icon: fa-home 9 | href: index.html 10 | - text: "Reference" 11 | icon: fas fa-paperclip 12 | href: reference/index.html 13 | right: 14 | - text: "Articles" 15 | icon: fas fa-book 16 | menu: 17 | - text: Journal 18 | href: https://cran.r-project.org/web/packages/LDheatmap/vignettes/LDheatmap.pdf 19 | - text: Example of Adding Tracks 20 | href: https://cran.r-project.org/web/packages/LDheatmap/vignettes/addTracks.pdf 21 | - text: Drawing LDheatmap from data in VCF format 22 | href: articles/vcfOnLDheatmap.html 23 | - icon: fa-github fa-lg 24 | text: "github" 25 | href: https://github.com/mcneney/LDheatmap/ 26 | -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | citHeader("To cite LDheatmap in publications use:") 2 | 3 | citEntry(entry="Article", 4 | title = "LDheatmap: An R Function for Graphical Display of Pairwise 5 | Linkage Disequilibria Between Single Nucleotide 6 | Polymorphisms.", 7 | author = personList(as.person("J.-H. Shin"), 8 | as.person("S. Blay"), 9 | as.person("B. McNeney"), 10 | as.person("J. Graham")), 11 | journal= "J Stat Soft", 12 | volume = 16, 13 | year = 2006, 14 | pages ="{Code Snippet 3}", 15 | url ="https://www.jstatsoft.org/article/view/v016c03", 16 | textVersion = 17 | paste("Shin J-H, Blay S, McNeney B and Graham J (2006).", 18 | "LDheatmap: An R Function for Graphical Display of Pairwise Linkage 19 | Disequilibria Between Single Nucleotide Polymorphisms.", 20 | "J Stat Soft, 16 Code Snippet 3") 21 | ) 22 | -------------------------------------------------------------------------------- /src/RcppExports.cpp: -------------------------------------------------------------------------------- 1 | // Generated by using Rcpp::compileAttributes() -> do not edit by hand 2 | // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 3 | 4 | #include 5 | 6 | using namespace Rcpp; 7 | 8 | // GT_to_SnpMatrix 9 | S4 GT_to_SnpMatrix(CharacterMatrix GT, bool phased); 10 | RcppExport SEXP _LDheatmap_GT_to_SnpMatrix(SEXP GTSEXP, SEXP phasedSEXP) { 11 | BEGIN_RCPP 12 | Rcpp::RObject rcpp_result_gen; 13 | Rcpp::RNGScope rcpp_rngScope_gen; 14 | Rcpp::traits::input_parameter< CharacterMatrix >::type GT(GTSEXP); 15 | Rcpp::traits::input_parameter< bool >::type phased(phasedSEXP); 16 | rcpp_result_gen = Rcpp::wrap(GT_to_SnpMatrix(GT, phased)); 17 | return rcpp_result_gen; 18 | END_RCPP 19 | } 20 | 21 | static const R_CallMethodDef CallEntries[] = { 22 | {"_LDheatmap_GT_to_SnpMatrix", (DL_FUNC) &_LDheatmap_GT_to_SnpMatrix, 2}, 23 | {NULL, NULL, 0} 24 | }; 25 | 26 | RcppExport void R_init_LDheatmap(DllInfo *dll) { 27 | R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); 28 | R_useDynamicSymbols(dll, FALSE); 29 | } 30 | -------------------------------------------------------------------------------- /man/LDheatmap.addGrob.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/LDheatmap.addGrob.R 3 | \name{LDheatmap.addGrob} 4 | \alias{LDheatmap.addGrob} 5 | \title{Add a graphical object to an LDheatmap plot} 6 | \usage{ 7 | LDheatmap.addGrob(LDheatmap, grob, height = 0.2) 8 | } 9 | \arguments{ 10 | \item{LDheatmap}{An object of class LDheatmap.} 11 | 12 | \item{grob}{A graphical object of class\code{\link{grob}}.} 13 | 14 | \item{height}{The height of the viewport in which the grob will be placed.} 15 | } 16 | \value{ 17 | An object of class LDheatmap given as an argument, with the \code{grob} 18 | \code{LDheatmapGrob} modified to inclue the new child grob. 19 | } 20 | \description{ 21 | Add a graphical object to an LDheatmap plot such that the x-axis corresponds 22 | to the physical map on the heatmap. 23 | } 24 | \examples{ 25 | # Add an empty rectangle frame 26 | data(GIMAP5.CEU) 27 | ll<-LDheatmap(GIMAP5.CEU$snp.data,GIMAP5.CEU$snp.support$Position,flip=TRUE) 28 | llplusgrob<-LDheatmap.addGrob(ll, grid::rectGrob()) 29 | } 30 | \seealso{ 31 | \code{\link{LDheatmap}} 32 | } 33 | \author{ 34 | Sigal Blay 35 | } 36 | \keyword{hplot} 37 | -------------------------------------------------------------------------------- /R/LDheatmap.moveGenemap.R: -------------------------------------------------------------------------------- 1 | # Genemap moving function 2 | # Test movement with symbols on 3 | 4 | LDheatmap.moveGenemap <- function(LDheatmap, distance = "close"){ 5 | if(is.null(LDheatmap$flipVP)){ 6 | if(distance == "close") temp <- editGrob(LDheatmap$LDheatmapGrob, gPath("geneMap"), vp = viewport(x = unit(0.52, "snpc"), y = unit(0.48, "snpc"))) 7 | if(distance == "medium") temp <- editGrob(LDheatmap$LDheatmapGrob, gPath("geneMap"), vp = viewport(x = unit(0.56, "snpc"), y = unit(0.44, "snpc"))) 8 | if(distance == "far") temp <- editGrob(LDheatmap$LDheatmapGrob, gPath("geneMap"), vp = viewport(x = unit(0.60, "snpc"), y = unit(0.4, "snpc"))) 9 | } 10 | else{ 11 | if(distance == "close") temp <- editGrob(LDheatmap$LDheatmapGrob, gPath("geneMap"), vp = viewport(x = unit(0.5, "snpc"), y = unit(0.52, "snpc"))) 12 | if(distance == "medium") temp <- editGrob(LDheatmap$LDheatmapGrob, gPath("geneMap"), vp = viewport(x = unit(0.5, "snpc"), y = unit(0.56, "snpc"))) 13 | if(distance == "far") temp <- editGrob(LDheatmap$LDheatmapGrob, gPath("geneMap"), vp = viewport(x = unit(0.5, "snpc"), y = unit(0.6, "snpc"))) 14 | } 15 | LDheatmap$LDheatmapGrob <- temp 16 | grid.newpage() 17 | grid.draw(LDheatmap$LDheatmapGrob) 18 | return(LDheatmap) 19 | } 20 | -------------------------------------------------------------------------------- /R/CEUDataRd.R: -------------------------------------------------------------------------------- 1 | #' @name CEUSNP 2 | #' @aliases CEUDist 3 | #' CEUSNP 4 | #' CEUDist 5 | #' hapmapCEU 6 | #' @docType data 7 | #' @title Example data set for LDheatmap 8 | #'@description CEUSNP: Genotypes on 15 SNPs for 60 people 9 | #' 10 | #'CEUDist: Physical map positions of the 15 SNPs in CEUSNP 11 | #' 12 | #' @usage data(CEUSNP); data(CEUDist) 13 | #' @format CEUSNP: A dataframe of SNP genotypes. 14 | #' Each row represents an individual. 15 | #' Each column represents a SNP. 16 | #' 17 | #'CEUDist: A vector of integers, representing SNP physical map locations on the chromosome. 18 | #' @details Data on SNPs with minor allele frequency greater 19 | #'than 5\% from a 9kb region of chromosome 7 (base positions 126273659 20 | #' through 126282556 from release 7 of the International HapMap Project). 21 | #'Genotypes from 30 parent-offspring trios (both 22 | #' parents, one offspring) were obtained. 23 | #'The 30 trios are taken from the so-called CEPH families, a set of 24 | #'multi-generational families from Utah with ancestry from northern and 25 | #'western Europe. From this set of 90 people, 60 parents were extracted. 26 | #' @source International HapMap Project \url{ftp://ftp.ncbi.nlm.nih.gov/hapmap/} 27 | #' @references The International HapMap Consortium. A haplotype map of 28 | #'the human genome. Nature 437, 1299-1320. 2005. 29 | #'@examples data(CEUData) 30 | #'@keywords datasets 31 | NULL 32 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "LDheatmap" 3 | author: "Brad McNeney" 4 | date: '2018-05-14' 5 | output: html_document 6 | --- 7 | 8 | 9 | ```{r, include = FALSE} 10 | knitr::opts_chunk$set( 11 | echo = TRUE 12 | ) 13 | ``` 14 | 15 | ## LDheatmap 16 | 17 | `LDheatmap()` is used to produce a graphical display, as a heat map, of pairwise linkage disequilibrium (LD) 18 | measurements for SNPs. 19 | The heat map is a false color image in the upper-left 20 | diagonal of a square plot. A line parallel to 21 | the diagonal of the image indicating 22 | the physical or genetic map positions of the SNPs 23 | may be added, along 24 | with text reporting the total length of the genomic 25 | region considered. Users may also display the heatmap 26 | "flipped" below a horizontal line indicating the map 27 | positions of the SNPs. In this orientation, 28 | tracks may be added above the genetic map. 29 | 30 | ## Installation 31 | 32 | ```{r,eval=FALSE} 33 | # Install the latest release version from CRAN and the 34 | # imported/suggested BioConductor packages with 35 | install.packages("LDheatmap") 36 | source("https://bioconductor.org/biocLite.R") 37 | biocLite(c("snpStats","rtracklayer","GenomicRanges","GenomInfoDb","IRanges")) 38 | 39 | # Install the latest development version from GitHub with 40 | devtools::install_github("SFUStatgen/LDheatmap") 41 | ``` 42 | 43 | 44 | ## Homepage 45 | 46 | https://sfustatgen.github.io/LDheatmap/index.html 47 | 48 | -------------------------------------------------------------------------------- /man/CEUSNP.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/CEUDataRd.R 3 | \docType{data} 4 | \name{CEUSNP} 5 | \alias{CEUSNP} 6 | \alias{CEUDist} 7 | \alias{hapmapCEU} 8 | \title{Example data set for LDheatmap} 9 | \format{ 10 | CEUSNP: A dataframe of SNP genotypes. 11 | Each row represents an individual. 12 | Each column represents a SNP. 13 | 14 | CEUDist: A vector of integers, representing SNP physical map locations on the chromosome. 15 | } 16 | \source{ 17 | International HapMap Project \url{ftp://ftp.ncbi.nlm.nih.gov/hapmap/} 18 | } 19 | \usage{ 20 | data(CEUSNP); data(CEUDist) 21 | } 22 | \description{ 23 | CEUSNP: Genotypes on 15 SNPs for 60 people 24 | 25 | CEUDist: Physical map positions of the 15 SNPs in CEUSNP 26 | } 27 | \details{ 28 | Data on SNPs with minor allele frequency greater 29 | than 5\% from a 9kb region of chromosome 7 (base positions 126273659 30 | through 126282556 from release 7 of the International HapMap Project). 31 | Genotypes from 30 parent-offspring trios (both 32 | parents, one offspring) were obtained. 33 | The 30 trios are taken from the so-called CEPH families, a set of 34 | multi-generational families from Utah with ancestry from northern and 35 | western Europe. From this set of 90 people, 60 parents were extracted. 36 | } 37 | \examples{ 38 | data(CEUData) 39 | } 40 | \references{ 41 | The International HapMap Consortium. A haplotype map of 42 | the human genome. Nature 437, 1299-1320. 2005. 43 | } 44 | \keyword{datasets} 45 | -------------------------------------------------------------------------------- /man/recombRate.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/recombRate.R 3 | \name{recombRate} 4 | \alias{recombRate} 5 | \title{Produce recombination rate plot.} 6 | \usage{ 7 | recombRate(minRange, maxRange, chromosome, genome = "hg19", vp = viewport(x = 0, 8 | y = 0.99, height = 0.04, just = c("left", "top")), view = "dense") 9 | } 10 | \arguments{ 11 | \item{minRange}{The sequence minimum range in base pairs.} 12 | 13 | \item{maxRange}{The sequence maximum range in base pairs.} 14 | 15 | \item{chromosome}{A character string identifying the chromosome.} 16 | 17 | \item{genome}{The genome assembly to use. The default is hg19, the most recent human genome assembly on 18 | the UCSC genome browser.} 19 | 20 | \item{vp}{A \code{viewport}.} 21 | 22 | \item{view}{Display mode. Possible values are \code{"dense"} (the default), \code{"squish"}, 23 | \code{"pack"} and \code{"full"}.} 24 | } 25 | \value{ 26 | A \code{grob} representing recombination rates. 27 | } 28 | \description{ 29 | Plot average rates of recombination from the deCODE genetic map for a specified genetic sequence. 30 | } 31 | \examples{ 32 | \donttest{ 33 | grid::grid.newpage() 34 | recombRate(129000000, 140000000, "chr7", "hg18") 35 | grid::grid.newpage() 36 | grid::pushViewport(grid::viewport(width=0.8, x=0.2, just="left")) 37 | recombRate(129000000, 140000000, "chr7", "hg18", view="full") 38 | grid::popViewport() 39 | } 40 | } 41 | \references{ 42 | \url{http://genome.ucsc.edu/cgi-bin/hgTrackUi?g=recombRate} 43 | } 44 | \author{ 45 | Sigal Blay and more 46 | } 47 | \keyword{hplot} 48 | -------------------------------------------------------------------------------- /man/LDheatmap.addRecombRate.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/LDheatmap.addRecombRate.R 3 | \name{LDheatmap.addRecombRate} 4 | \alias{LDheatmap.addRecombRate} 5 | \title{Add recombination rate plot to an LD heat map.} 6 | \usage{ 7 | LDheatmap.addRecombRate(LDheatmap, chromosome, genome = NULL, recombRateLocation = 0.02, 8 | view = "dense") 9 | } 10 | \arguments{ 11 | \item{LDheatmap}{An object of class LDheatmap.} 12 | 13 | \item{chromosome}{A character string that identifies the chromosome.} 14 | 15 | \item{genome}{The genome assembly to use. The default is the most recent human genome assembly on the UCSC Genome Browser.} 16 | 17 | \item{recombRateLocation}{The plot distance from the LD heat map gene map.} 18 | 19 | \item{view}{Display mode. Possible values are \code{"dense"} (the default), \code{"squish"}, 20 | \code{"pack"} and \code{"full"}.} 21 | } 22 | \value{ 23 | An object of class LDheatmap given as an argument, with the \code{grob} 24 | \code{LDheatmapGrob} modified to inclue the \code{"recombRate"} child grob. 25 | } 26 | \description{ 27 | Retrieve average rates of recombination from the deCODE genetic map from the UCSC 28 | Genome Browser and add them to an LDheatmap object. 29 | } 30 | \examples{ 31 | \donttest{ 32 | data(GIMAP5.CEU) 33 | ll<-LDheatmap(GIMAP5.CEU$snp.data,GIMAP5.CEU$snp.support$Position,flip=TRUE) 34 | # Add recombination rate plot 35 | ll_recomb <- LDheatmap.addRecombRate(ll, chr="chr7", genome="hg18") 36 | } 37 | } 38 | \references{ 39 | \url{http://genome.ucsc.edu/cgi-bin/hgTrackUi?g=recombRate} 40 | } 41 | \seealso{ 42 | \code{\link{LDheatmap}}, \code{\link{recombRate}} 43 | } 44 | \author{ 45 | Sigal Blay 46 | } 47 | \keyword{hplot} 48 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: LDheatmap 2 | Version: 1.0-5 3 | Date: 2022-05-03 4 | Title: Graphical Display of Pairwise Linkage Disequilibria Between SNPs 5 | Authors@R: c(person("Ji-Hyung","Shin",email="shin@sfu.ca", role="aut"), 6 | person("Sigal","Blay", email="sblay@sfu.ca",role="aut"), 7 | person("Nicholas","Lewin-Koh",email="nikko@hailmail.net", role="ctb"), 8 | person("Brad","McNeney",email="mcneney@sfu.ca",role=c("aut","cre")), 9 | person("Gloria","Yang",email="xuefei_yang@sfu.ca",role="ctb"), 10 | person("Matthew","Reyers",email="matthew_reyers@sfu.ca",role="ctb"), 11 | person("Youwei","Yan",email="youweiy@sfu.ca",role="ctb"), 12 | person("Jinko","Graham",email="jgraham@sfu.ca",role="aut")) 13 | Maintainer: Brad McNeney 14 | Depends: R (>= 4.0) 15 | Imports: grid, genetics, snpStats, Rcpp 16 | Suggests: rtracklayer, GenomicRanges, GenomeInfoDb, IRanges, lattice, ggplot2, vcfR, RColorBrewer 17 | Description: Produces a graphical display, as a heat map, of measures 18 | of pairwise linkage disequilibria between single nucleotide polymorphisms (SNPs). Users may 19 | optionally include the physical locations or genetic map 20 | distances of each SNP on the plot. The methods are described in 21 | Shin et al. (2006) . Users should note that the 22 | imported package 'snpStats' and the suggested packages 23 | 'rtracklayer', 'GenomicRanges', 'GenomInfoDb' and 'IRanges' are all 24 | BioConductor packages . 25 | License: GPL-3 26 | URL: https://sfustatgen.github.io/LDheatmap/ 27 | Repository: CRAN 28 | Date/Publication: 2010-01-11 19:57:39 29 | RoxygenNote: 7.1.2 30 | LinkingTo: Rcpp 31 | -------------------------------------------------------------------------------- /R/GIMAP5CEUrd.R: -------------------------------------------------------------------------------- 1 | #' @name GIMAP5.CEU 2 | #' @aliases GIMAP5.CEU 3 | #' @docType data 4 | #' @title Example data set for LDheatmap 5 | #' @description SNP genotypes on HapMap founders from the CEU population 6 | #'for SNPs spanning the GIMAP5 gene. 7 | #' @usage data(GIMAP5.CEU) 8 | #' @format GIMAP5.CEU is a list with two elements: snp.data and snp.support. 9 | #'snp.data is a \code{SnpMatrix} 10 | #'object containing the SNP genotypes. Rows correspond to 11 | #'subjects and columns correspond to SNPs. 12 | #'snp.support is a data frame with the following columns: 13 | #'\tabular{rlll}{ 14 | #'[,1] \tab dbSNPalleles \tab character \tab alleles at each SNP\cr 15 | #'[,2] \tab Assignment \tab character \tab same as dbSNPalleles\cr 16 | #'[,3] \tab Chromosome \tab character \tab chromosome (chr7 for all)\cr 17 | #'[,4] \tab Position \tab numeric \tab physical position\cr 18 | #'[,5] \tab Strand \tab character \tab strand (all "+")\cr 19 | #'} 20 | #' @details SNP genotypes from HapMap release 27 21 | #'for SNPs in a 10KB region spanning 22 | #'the GIMAP5 gene. Data are on founders from the CEU population, 23 | #'described as Utah residents with Northern and Western European ancestry 24 | #'from the CEPH collection. 25 | #'Only those SNPs with minor allele frequency greater 26 | #'than 5\% in all populations were retained. 27 | #'The base positions are from NCBI build 36 28 | #'(UCSC genome hg18). 29 | #' @source International HapMap Project \url{ftp://ftp.ncbi.nlm.nih.gov/hapmap/} 30 | #' @references The International HapMap Consortium. A haplotype map of 31 | #'the human genome. Nature 437, 1299-1320. 2005. 32 | #' @seealso \code{\link{GIMAP5}} 33 | #' @examples require(snpStats) # for the SnpMatrix data structure 34 | #'data(GIMAP5.CEU) 35 | #'LDheatmap(GIMAP5.CEU$snp.data,GIMAP5.CEU$snp.support$Position) 36 | #' 37 | #' @keywords dataset 38 | NULL 39 | -------------------------------------------------------------------------------- /R/CHBJPTDataRd.R: -------------------------------------------------------------------------------- 1 | #' @name CHBJPTSNP 2 | #' @aliases CHBJPTDist 3 | #' CHBJPTSNP 4 | #' CHBJPTDist 5 | #' hapmapJPT 6 | #' hapmapCHB 7 | #' @docType data 8 | #' @title Example of data set for LDHeatmap 9 | #' @description CHBJPTSNP: Genotypes on 13 SNPs for 45 Chinese and 45 Japanese people 10 | #' CHBJPTDist: Physical map positions of the 13 SNPs 11 | #' @usage data(CHBJPTSNP); data(CHBJPTDist) 12 | #' @format CHBJPTSNP: A dataframe of SNP genotypes. 13 | #' Each row represents an individual. 14 | #' Each column represents a SNP. 15 | #' 16 | #' CHBJPTDist: a vector of integers, representing SNP physical map 17 | #' locations on the chromosome. 18 | #' @details The data frame \code{CHBJPTSNP} contains genotypes for 13 SNPs on chromosome 7, 19 | #' from 45 Chinese and 45 Japanese individuals. 20 | #' The Chinese individuals were unrelated residents of the community at Beijing Normal 21 | #' University with at least 3 Han Chinese grandparents. 22 | #' The Japanese individuals were unrelated residents of the Tokyo metropolitan 23 | #' area with all grandparents from Japan. The data are from release 21 of the 24 | #' International HapMap project (The International HapMap Consortium 2005). 25 | #' @source International HapMap Project \url{ftp://ftp.ncbi.nlm.nih.gov/hapmap/} 26 | #' @references The International HapMap Consortium. A haplotype map of 27 | #' the human genome. Nature 437, 1299-1320. 2005. 28 | #' @examples data(CHBJPTData) 29 | #'#Now do our panel plot with LDheatmaps in the panels 30 | #'library(lattice) 31 | #'pop<-factor(c(rep("chinese", 45), rep("japanese", 45))) 32 | #'xyplot(1:nrow(CHBJPTSNP) ~ 1:nrow(CHBJPTSNP) | pop, type="n", 33 | #' scales=list(draw=FALSE), xlab="", ylab="", 34 | #' panel=function(x, y, subscripts,...) { 35 | #' LDheatmap(CHBJPTSNP[subscripts,], CHBJPTDist, newpage=FALSE)}) 36 | #' @keywords datasets 37 | NULL 38 | -------------------------------------------------------------------------------- /docs/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | https://github.com/mcneney/LDheatmap/index.html 5 | 6 | 7 | https://github.com/mcneney/LDheatmap/reference/CEUData.html 8 | 9 | 10 | https://github.com/mcneney/LDheatmap/reference/CHBJPTData.html 11 | 12 | 13 | https://github.com/mcneney/LDheatmap/reference/GIMAP5.CEU.html 14 | 15 | 16 | https://github.com/mcneney/LDheatmap/reference/GIMAP5.html 17 | 18 | 19 | https://github.com/mcneney/LDheatmap/reference/LDheatmap-internal.html 20 | 21 | 22 | https://github.com/mcneney/LDheatmap/reference/LDheatmap.html 23 | 24 | 25 | https://github.com/mcneney/LDheatmap/reference/LDheatmap.addGenes.html 26 | 27 | 28 | https://github.com/mcneney/LDheatmap/reference/LDheatmap.addGrob.html 29 | 30 | 31 | https://github.com/mcneney/LDheatmap/reference/LDheatmap.addRecombRate.html 32 | 33 | 34 | https://github.com/mcneney/LDheatmap/reference/LDheatmap.addScatterplot.html 35 | 36 | 37 | https://github.com/mcneney/LDheatmap/reference/LDheatmap.highlight.html 38 | 39 | 40 | https://github.com/mcneney/LDheatmap/reference/LDheatmap.marks.html 41 | 42 | 43 | https://github.com/mcneney/LDheatmap/reference/plotGenes.html 44 | 45 | 46 | https://github.com/mcneney/LDheatmap/reference/recombRate.html 47 | 48 | 49 | https://github.com/mcneney/LDheatmap/articles/vcfOnLDheatmap.html 50 | 51 | 52 | -------------------------------------------------------------------------------- /man/plotGenes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotGenes.R 3 | \name{plotGenes} 4 | \alias{plotGenes} 5 | \title{Plot genes from a specified region of the human genome.} 6 | \usage{ 7 | plotGenes(minRange, maxRange, chromosome, genome = "hg19", plot_lines_distance = 0.03, 8 | vp = viewport(x = 0, y = 0.99, just = c("left", "top")), splice_variants = TRUE, 9 | non_coding = TRUE) 10 | } 11 | \arguments{ 12 | \item{minRange}{The sequence minimum range in base pairs.} 13 | 14 | \item{maxRange}{The sequence maximum range in base pairs.} 15 | 16 | \item{chromosome}{A character string identifying the chromosome.} 17 | 18 | \item{genome}{The genome assembly to use. The default is hg19, the most recent human genome assembly on 19 | the UCSC genome browser.} 20 | 21 | \item{plot_lines_distance}{The distance between the lines of genes plotted.} 22 | 23 | \item{vp}{A \code{viewport}.} 24 | 25 | \item{splice_variants}{If \code{FALSE}, exclude gene splice variants.} 26 | 27 | \item{non_coding}{If \code{FALSE}, exclude non-coding genes.} 28 | } 29 | \value{ 30 | A \code{grob} of gene plots. 31 | } 32 | \description{ 33 | Retrieves genes from the UCSC Genome Browser and generate the genes plot. 34 | } 35 | \details{ 36 | The genes are color coded as follows: 37 | Black -- feature has a corresponding entry in the Protein Data Bank (PDB) 38 | Dark blue -- transcript has been reviewed or validated by either the RefSeq, SwissProt or CCDS staff 39 | Medium blue -- other RefSeq transcripts 40 | Light blue -- non-RefSeq transcripts 41 | 42 | For assemblies older than hg18, all genes are plotted in grey. 43 | } 44 | \examples{ 45 | \donttest{ 46 | grid::grid.newpage() 47 | plotGenes(149500000, 150000000, "chr7") 48 | } 49 | } 50 | \references{ 51 | \url{http://genome.ucsc.edu/cgi-bin/hgTrackUi?g=knownGene} 52 | } 53 | \author{ 54 | Sigal Blay and more 55 | } 56 | \keyword{hplot} 57 | -------------------------------------------------------------------------------- /man/CHBJPTSNP.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/CHBJPTDataRd.R 3 | \docType{data} 4 | \name{CHBJPTSNP} 5 | \alias{CHBJPTSNP} 6 | \alias{CHBJPTDist} 7 | \alias{hapmapJPT} 8 | \alias{hapmapCHB} 9 | \title{Example of data set for LDHeatmap} 10 | \format{ 11 | CHBJPTSNP: A dataframe of SNP genotypes. 12 | Each row represents an individual. 13 | Each column represents a SNP. 14 | 15 | CHBJPTDist: a vector of integers, representing SNP physical map 16 | locations on the chromosome. 17 | } 18 | \source{ 19 | International HapMap Project \url{ftp://ftp.ncbi.nlm.nih.gov/hapmap/} 20 | } 21 | \usage{ 22 | data(CHBJPTSNP); data(CHBJPTDist) 23 | } 24 | \description{ 25 | CHBJPTSNP: Genotypes on 13 SNPs for 45 Chinese and 45 Japanese people 26 | CHBJPTDist: Physical map positions of the 13 SNPs 27 | } 28 | \details{ 29 | The data frame \code{CHBJPTSNP} contains genotypes for 13 SNPs on chromosome 7, 30 | from 45 Chinese and 45 Japanese individuals. 31 | The Chinese individuals were unrelated residents of the community at Beijing Normal 32 | University with at least 3 Han Chinese grandparents. 33 | The Japanese individuals were unrelated residents of the Tokyo metropolitan 34 | area with all grandparents from Japan. The data are from release 21 of the 35 | International HapMap project (The International HapMap Consortium 2005). 36 | } 37 | \examples{ 38 | data(CHBJPTData) 39 | #Now do our panel plot with LDheatmaps in the panels 40 | library(lattice) 41 | pop<-factor(c(rep("chinese", 45), rep("japanese", 45))) 42 | xyplot(1:nrow(CHBJPTSNP) ~ 1:nrow(CHBJPTSNP) | pop, type="n", 43 | scales=list(draw=FALSE), xlab="", ylab="", 44 | panel=function(x, y, subscripts,...) { 45 | LDheatmap(CHBJPTSNP[subscripts,], CHBJPTDist, newpage=FALSE)}) 46 | } 47 | \references{ 48 | The International HapMap Consortium. A haplotype map of 49 | the human genome. Nature 437, 1299-1320. 2005. 50 | } 51 | \keyword{datasets} 52 | -------------------------------------------------------------------------------- /man/GIMAP5.CEU.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/GIMAP5CEUrd.R 3 | \docType{data} 4 | \name{GIMAP5.CEU} 5 | \alias{GIMAP5.CEU} 6 | \title{Example data set for LDheatmap} 7 | \format{ 8 | GIMAP5.CEU is a list with two elements: snp.data and snp.support. 9 | snp.data is a \code{SnpMatrix} 10 | object containing the SNP genotypes. Rows correspond to 11 | subjects and columns correspond to SNPs. 12 | snp.support is a data frame with the following columns: 13 | \tabular{rlll}{ 14 | [,1] \tab dbSNPalleles \tab character \tab alleles at each SNP\cr 15 | [,2] \tab Assignment \tab character \tab same as dbSNPalleles\cr 16 | [,3] \tab Chromosome \tab character \tab chromosome (chr7 for all)\cr 17 | [,4] \tab Position \tab numeric \tab physical position\cr 18 | [,5] \tab Strand \tab character \tab strand (all "+")\cr 19 | } 20 | } 21 | \source{ 22 | International HapMap Project \url{ftp://ftp.ncbi.nlm.nih.gov/hapmap/} 23 | } 24 | \usage{ 25 | data(GIMAP5.CEU) 26 | } 27 | \description{ 28 | SNP genotypes on HapMap founders from the CEU population 29 | for SNPs spanning the GIMAP5 gene. 30 | } 31 | \details{ 32 | SNP genotypes from HapMap release 27 33 | for SNPs in a 10KB region spanning 34 | the GIMAP5 gene. Data are on founders from the CEU population, 35 | described as Utah residents with Northern and Western European ancestry 36 | from the CEPH collection. 37 | Only those SNPs with minor allele frequency greater 38 | than 5\% in all populations were retained. 39 | The base positions are from NCBI build 36 40 | (UCSC genome hg18). 41 | } 42 | \examples{ 43 | require(snpStats) # for the SnpMatrix data structure 44 | data(GIMAP5.CEU) 45 | LDheatmap(GIMAP5.CEU$snp.data,GIMAP5.CEU$snp.support$Position) 46 | 47 | } 48 | \references{ 49 | The International HapMap Consortium. A haplotype map of 50 | the human genome. Nature 437, 1299-1320. 2005. 51 | } 52 | \seealso{ 53 | \code{\link{GIMAP5}} 54 | } 55 | \keyword{dataset} 56 | -------------------------------------------------------------------------------- /data-raw/CHBJPTData.R: -------------------------------------------------------------------------------- 1 | #Downloaded SNP data for 45 unrelated Chinese and 45 (actually really 44) 2 | #unrelated Japanese from HapMap, Data Release #21/phaseII Jul06, base-pair 3 | #range same as in original example data for LDheatmap from Utah CEPH families. 4 | 5 | ch.dat<-utils::read.table("hapmapCHB.txt",header=TRUE) #rows are SNPs! 6 | names(ch.dat) #to see which columns give the people for a SNP (row) 7 | snpnames.ch<-ch.dat[,"rsnum"] #names of snps 8 | ch.snps<-t(ch.dat[,12:56]) #snp data - rows index people, cols index SNPs 9 | 10 | jp.dat<-utils::read.table("hapmapJPT.txt", header=TRUE) 11 | names(jp.dat) #to see which columns give the people for a SNP (row) 12 | snpnames.jp<-jp.dat[,"rsnum"] #names of snps 13 | jp.snps<-t(jp.dat[,12:56]) #snp data - rows index people, cols index SNPs 14 | 15 | #Are the SNPs genotyped in the Chinese and Japanese the same? 16 | all(snpnames.ch==snpnames.jp) #Yes, all are the same 17 | 18 | #Make a variable that indicates chinese vs japanese 19 | #Glue together the data for chinese and japanese 20 | CHBJPTSNP<-data.frame(rbind(ch.snps,jp.snps)) 21 | names(CHBJPTSNP)<-c(as.character(snpnames.jp)) 22 | 23 | #Loop over the columns of CHBJPTSNP to replace the missing 24 | #genotypes (coded as NN) and convert them to genotype objects 25 | library(genetics) 26 | for(i in 1:41) { 27 | tem<-as.character(CHBJPTSNP[,i]) #Currently columns are factors 28 | tem[tem=="NN"]<-"" 29 | CHBJPTSNP[,i]<-genetics::genotype(tem,sep="") 30 | } 31 | 32 | #Remove any SNPs that are not sufficiently polymorphic in either 33 | #Chinese or Japanese 34 | ind<-rep(NA,41) 35 | for(i in 1:41) 36 | ind[i]<-summary(CHBJPTSNP[1:45,i])$Hu>0&summary(CHBJPTSNP[46:90,i])$Hu>0 37 | CHBJPTSNP<-CHBJPTSNP[,ind] #only 13! 38 | 39 | #Create a vector of base-pair positions for the 13 SNPs. Need to go 40 | #back to the ch.dat (or jp.dat) data frames to find the positions in 41 | #a column named "pos". 42 | 43 | CHBJPTDist<-ch.dat[,"pos"] 44 | CHBJPTDist<-CHBJPTDist[ind] 45 | 46 | rm(ch.dat,ch.snps,i,ind,jp.dat,jp.snps,snpnames.ch,snpnames.jp,tem) 47 | 48 | usethis::use_data(CHBJPTSNP,CHBJPTDist, overwrite = TRUE) 49 | -------------------------------------------------------------------------------- /man/LDheatmap.addGenes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/LDheatmap.addGenes.R 3 | \name{LDheatmap.addGenes} 4 | \alias{LDheatmap.addGenes} 5 | \title{Add gene plot to an LDheatmap object.} 6 | \usage{ 7 | LDheatmap.addGenes(LDheatmap, chromosome, genome = NULL, genesLocation = 0.02, 8 | splice_variants = TRUE, non_coding = TRUE) 9 | } 10 | \arguments{ 11 | \item{LDheatmap}{An object of class LDheatmap.} 12 | 13 | \item{chromosome}{A character string that identifies the chromosome.} 14 | 15 | \item{genome}{The genome assembly to use. The default is the most recent human genome assembly on the UCSC genome browser.} 16 | 17 | \item{genesLocation}{The gene plot distance from the LD heat map gene map.} 18 | 19 | \item{splice_variants}{If \code{FALSE}, exclude gene splice variants.} 20 | 21 | \item{non_coding}{If \code{FALSE}, exclude non-coding genes.} 22 | } 23 | \value{ 24 | An object of class LDheatmap given as an argument, with the \code{grob} 25 | \code{LDheatmapGrob} modified to inclue the \code{"transcripts"} child grob. 26 | } 27 | \description{ 28 | Retrieve genes from the UCSC Genome Browser, generate the genes plot and add it to 29 | an LDheatmap object. 30 | } 31 | \details{ 32 | Note: The \code{LDheatmap} object should have a non-NULL \code{genetic.distances} 33 | component. Otherwise the gene map will not be placed correctly. 34 | The genes are color coded as follows: 35 | black -- feature has a corresponding entry in the Protein Data Bank (PDB); 36 | dark blue -- transcript has been reviewed or validated by either the RefSeq, SwissProt or CCDS staff; 37 | medium blue -- other RefSeq transcripts; and 38 | light blue -- non-RefSeq transcripts. 39 | 40 | For assemblies older than hg18, all genes are plotted in grey. 41 | } 42 | \examples{ 43 | \donttest{ 44 | data(GIMAP5.CEU) 45 | ll<-LDheatmap(GIMAP5.CEU$snp.data,GIMAP5.CEU$snp.support$Position,flip=TRUE) 46 | # Add gene plot 47 | llplusgenes <- LDheatmap.addGenes(ll, chr="chr7", genome="hg18") 48 | } 49 | } 50 | \references{ 51 | \url{http://genome.ucsc.edu/cgi-bin/hgTrackUi?g=knownGene} 52 | } 53 | \seealso{ 54 | \code{\link{LDheatmap}}, \code{\link{plotGenes}} 55 | } 56 | \author{ 57 | Sigal Blay 58 | } 59 | \keyword{hplot} 60 | -------------------------------------------------------------------------------- /vignettes/vcfOnLDheatmap.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Drawing LDheatmap from data in VCF format" 3 | author: "Gloria Yang" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{Drawing LDheatmap from data in VCF format} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | ```{r setup, include = FALSE} 13 | knitr::opts_chunk$set( 14 | collapse = TRUE, 15 | comment = "#>" 16 | ) 17 | ``` 18 | 19 | #Introduction 20 | VCF (Variant Call Format) is a text file format. It contains meta-information lines, a header line, and then data lines each containing information about a position in the genome. There is an example how to do draw LDheatmap from data in VCF format 21 | 22 | #Getting started 23 | `1KG_sample_info.csv` is the data file which contain the information about the sample population and corresponding super population code. We extract the population code of European descent and Asian descent for later use. 24 | ```{r} 25 | #super population for EUR & EAS 26 | #Get the corresponding population code for EUR & EAS 27 | sample_info <- read.csv("1KG_sample_info.csv") 28 | eur <- sample_info[sample_info$Population %in% c("CEU","TSI","FIN","GBR","IBS"),-c(2,4)] 29 | eas <- sample_info[sample_info$Population %in% c("CHB","JPT","CHS","CDX","KHV"),-c(2,4)] 30 | 31 | ``` 32 | 33 | `snp_in_vcf.vcf` is a vcf datafile contains common SNPs (SNPs with frequency 5% or more in the world-wide population) in the MLLT3 gene. We are going to draw 2 different LDheatmaps based on the genotype data contained in the file and the population code we just extracted. 34 | 35 | ```{r, warning=FALSE} 36 | library(vcfR) 37 | #read the VCF file and store the vcfR object 38 | vcf <- read.vcfR("snp_in_vcf.vcf") 39 | 40 | library(LDheatmap) 41 | #extract genetic distances, subject IDs and genotypes for European desent from the vcfR object 42 | list_eur <- vcfR2SnpMatrix(vcf, subjects = eur[,1]) 43 | 44 | #draw the heatmap 45 | LDheatmap(list_eur$data, list_eur$genetic.distance, title='Europeans', add.map=FALSE) 46 | 47 | #same procedure as above for Asian descent 48 | list_eas <- vcfR2SnpMatrix(vcf, subjects = eas[,1]) 49 | LDheatmap(list_eas$data, list_eas$genetic.distance, title='Asians', add.map=FALSE) 50 | 51 | ``` 52 | 53 | 54 | -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /man/vcfR2SnpMatrix.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/vcfR2SnpMatrix.R 3 | \name{vcfR2SnpMatrix} 4 | \alias{vcfR2SnpMatrix} 5 | \title{Extract genotype information from a vcfR object} 6 | \usage{ 7 | vcfR2SnpMatrix(obj, phased = NULL, subjects = NULL) 8 | } 9 | \arguments{ 10 | \item{obj}{An instance or path of the \code{\link[vcfR]{vcfR-class}} object to be processed.} 11 | 12 | \item{phased}{If \code{TRUE} the output genotype data are in the form of a \code{\link[snpStats]{XSnpMatrix-class}} object. Otherwise, they are in the form of a \code{\link[snpStats]{SnpMatrix-class}} object. 13 | If it is unspecified, the phasing status will be determined by checking the first entry in the gt slot of the vcfR object. If the first entry is also missing, the value will be set to \code{FALSE}.} 14 | 15 | \item{subjects}{A character or factor containing subject IDs. If supplied, genotype info of only those subjects will be returned. 16 | This should be a subset of the sample IDs in the vcfR object.} 17 | } 18 | \value{ 19 | A list which contains the following components: 20 | \item{genetic.distances}{ A numeric vector of the reference positions of SNPs. } 21 | \item{subjectID}{ A character vector of IDs of the subjects which the returned genotype data belong to. } 22 | \item{data}{An object of \code{\link[snpStats]{SnpMatrix-class}}/\code{\link[snpStats]{XSnpMatrix-class}} containing genotype data. } 23 | } 24 | \description{ 25 | Convert a \code{\link[vcfR]{vcfR-class}} object into a list composed of genetic distances, subject IDs, and a \code{\link[snpStats]{SnpMatrix-class}}/\code{\link[snpStats]{XSnpMatrix-class}} object. 26 | } 27 | \details{ 28 | In order to let \code{ vcfR2SnpMatrix} function properly, the input \code{\link[vcfR]{vcfR-class}} object is expected to be generated from a valid VCF file which contains only biallelic SNPs and includes a GT section. 29 | } 30 | \examples{ 31 | # Load the vcfR object -- requires vcfR 32 | if (requireNamespace("vcfR", quietly = TRUE)) { 33 | require(vcfR) 34 | data(vcfR_example) 35 | vcf <- vcf[8:12,] 36 | # Extract needed genotype information 37 | alist <- vcfR2SnpMatrix(vcf) 38 | 39 | # Draw a pairwise LD plot using the extracted data 40 | LDheatmap(alist$data, alist$genetic.distance) 41 | } 42 | 43 | } 44 | \seealso{ 45 | \code{\link[vcfR]{io_vcfR}}, \code{\link[snpStats]{SnpMatrix-class}}, \code{\link[snpStats]{XSnpMatrix-class}} 46 | } 47 | \keyword{hplot} 48 | -------------------------------------------------------------------------------- /docs/jquery.sticky-kit.min.js: -------------------------------------------------------------------------------- 1 | /* Sticky-kit v1.1.2 | WTFPL | Leaf Corcoran 2015 | */ 2 | /* 3 | Source: https://github.com/leafo/sticky-kit 4 | License: MIT 5 | */ 6 | (function(){var b,f;b=this.jQuery||window.jQuery;f=b(window);b.fn.stick_in_parent=function(d){var A,w,J,n,B,K,p,q,k,E,t;null==d&&(d={});t=d.sticky_class;B=d.inner_scrolling;E=d.recalc_every;k=d.parent;q=d.offset_top;p=d.spacer;w=d.bottoming;null==q&&(q=0);null==k&&(k=void 0);null==B&&(B=!0);null==t&&(t="is_stuck");A=b(document);null==w&&(w=!0);J=function(a,d,n,C,F,u,r,G){var v,H,m,D,I,c,g,x,y,z,h,l;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);I=A.height();g=a.parent();null!=k&&(g=g.closest(k)); 7 | if(!g.length)throw"failed to find stick parent";v=m=!1;(h=null!=p?p&&a.closest(p):b("
"))&&h.css("position",a.css("position"));x=function(){var c,f,e;if(!G&&(I=A.height(),c=parseInt(g.css("border-top-width"),10),f=parseInt(g.css("padding-top"),10),d=parseInt(g.css("padding-bottom"),10),n=g.offset().top+c+f,C=g.height(),m&&(v=m=!1,null==p&&(a.insertAfter(h),h.detach()),a.css({position:"",top:"",width:"",bottom:""}).removeClass(t),e=!0),F=a.offset().top-(parseInt(a.css("margin-top"),10)||0)-q, 8 | u=a.outerHeight(!0),r=a.css("float"),h&&h.css({width:a.outerWidth(!0),height:u,display:a.css("display"),"vertical-align":a.css("vertical-align"),"float":r}),e))return l()};x();if(u!==C)return D=void 0,c=q,z=E,l=function(){var b,l,e,k;if(!G&&(e=!1,null!=z&&(--z,0>=z&&(z=E,x(),e=!0)),e||A.height()===I||x(),e=f.scrollTop(),null!=D&&(l=e-D),D=e,m?(w&&(k=e+u+c>C+n,v&&!k&&(v=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom"))),eb&&!v&&(c-=l,c=Math.max(b-u,c),c=Math.min(q,c),m&&a.css({top:c+"px"})))):e>F&&(m=!0,b={position:"fixed",top:c},b.width="border-box"===a.css("box-sizing")?a.outerWidth()+"px":a.width()+"px",a.css(b).addClass(t),null==p&&(a.after(h),"left"!==r&&"right"!==r||h.append(a)),a.trigger("sticky_kit:stick")),m&&w&&(null==k&&(k=e+u+c>C+n),!v&&k)))return v=!0,"static"===g.css("position")&&g.css({position:"relative"}), 10 | a.css({position:"absolute",bottom:d,top:"auto"}).trigger("sticky_kit:bottom")},y=function(){x();return l()},H=function(){G=!0;f.off("touchmove",l);f.off("scroll",l);f.off("resize",y);b(document.body).off("sticky_kit:recalc",y);a.off("sticky_kit:detach",H);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:"",width:""});g.position("position","");if(m)return null==p&&("left"!==r&&"right"!==r||a.insertAfter(h),h.remove()),a.removeClass(t)},f.on("touchmove",l),f.on("scroll",l),f.on("resize", 11 | y),b(document.body).on("sticky_kit:recalc",y),a.on("sticky_kit:detach",H),setTimeout(l,0)}};n=0;for(K=this.length;n 13 | #' @seealso \code{\link{LDheatmap}} 14 | #' @examples # Add an empty rectangle frame 15 | #'data(GIMAP5.CEU) 16 | #'ll<-LDheatmap(GIMAP5.CEU$snp.data,GIMAP5.CEU$snp.support$Position,flip=TRUE) 17 | #'llplusgrob<-LDheatmap.addGrob(ll, grid::rectGrob()) 18 | #' @keywords hplot 19 | #' @export 20 | 21 | # ldheatmap - Plots measures of pairwise linkage disequilibria for SNPs 22 | # Copyright (C) 2004 J.Shin, S. Blay, N. Lewin-Koh, J.Graham, B.McNeney 23 | 24 | # To cite LDheatmap in publications use: 25 | # Shin J-H, Blay S, McNeney B and Graham J (2006). LDheatmap: An R 26 | # Function for Graphical Display of Pairwise Linkage Disequilibria 27 | # Between Single Nucleotide Polymorphisms. J Stat Soft, 16 Code Snippet 3 28 | 29 | # This program is free software; you can redistribute it and/or modify 30 | # it under the terms of the GNU General Public License as published by 31 | # the Free Software Foundation; either version 2 of the License, or 32 | # (at your option) any later version. 33 | 34 | # This program is distributed in the hope that it will be useful, 35 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 36 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 37 | # GNU General Public License for more details. 38 | 39 | # You should have received a copy of the GNU General Public License 40 | # along with this program; if not, write to the Free Software 41 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 42 | 43 | ########################################################################### 44 | 45 | 46 | #_______________________Add a user-defined grob_____________________________________## 47 | LDheatmap.addGrob <- function(LDheatmap, grob, height=0.2) { 48 | requireNamespace("grid") 49 | flip <- !is.null(LDheatmap$flipVP) 50 | vp <- constructVP(LDheatmap$LDheatmapGrob, 0.03, flip) 51 | vp$height <- unit(height, "npc") 52 | vpstack <- vp; if(flip) vpstack <- vpStack(LDheatmap$flipVP,vp) 53 | grob <- gTree(children=gList(grob), vp=vpstack) 54 | LDheatmap$LDheatmapGrob <- addGrob(LDheatmap$LDheatmapGrob, grob) 55 | LDheatmap$LDheatmapGrob <- moveTitles(LDheatmap$LDheatmapGrob, vp) 56 | return(LDheatmap) 57 | } 58 | 59 | -------------------------------------------------------------------------------- /vignettes/LDheatmap.bib: -------------------------------------------------------------------------------- 1 | @manual{Sarkar:lattice, 2 | Author = {Deepayan Sarker}, 3 | Title = {\pkg{lattice}: Lattice Graphics}, 4 | Note = {\proglang{R} package version 0.13-10}, 5 | Year = {2006}} 6 | 7 | @article{Murrell99, 8 | Author = {Paul Murrell}, 9 | Journal = {Journal of Computational and Graphical Statistics}, 10 | Pages = {121--134}, 11 | Title = {Layouts: A Mechanism for Arranging Plots on a Page}, 12 | Volume = {8}, 13 | Year = {1999}} 14 | 15 | @manual{gridpkg, 16 | Author = {Paul Murrell}, 17 | Note = {\proglang{R} package version 2.3.1}, 18 | Title = {The Grid Graphics Package}, 19 | Year = {2006}} 20 | 21 | @misc{Murrell06:modgrobs, 22 | Author = {Paul Murrell}, 23 | Note = {\proglang{R} \pkg{grid} package vignette}, 24 | Title = {Modifying \pkg{grid} \code{grob}s}, 25 | Year = {2006}} 26 | 27 | @manual{R, 28 | Address = {Vienna, Austria}, 29 | Author = {{\proglang{R} Development Core Team}}, 30 | Note = {{ISBN} 3-900051-07-0}, 31 | Organization = {\proglang{R} Foundation for Statistical Computing}, 32 | Title = {\proglang{R}: A Language and Environment for Statistical Computing}, 33 | Url = {http://www.R-project.org/}, 34 | Year = {2006}} 35 | 36 | @misc{Murrell06:VP, 37 | Author = {Paul Murrell}, 38 | Note = {\proglang{R} \pkg{grid} package vignette}, 39 | Title = {Working with \pkg{grid} Viewports}, 40 | Year = {2006}} 41 | 42 | @misc{Murrell06:editgrobs, 43 | Author = {Paul Murrell}, 44 | Note = {\proglang{R} \pkg{grid} package vignette}, 45 | Title = {An Example of Interactive Graphics Editing in \pkg{grid}}, 46 | Year = {2006}} 47 | 48 | @book{Murrell05, 49 | Address = {Boca Raton, Florida}, 50 | Author = {Paul Murrell}, 51 | Publisher = {Chapman \& Hall/CRC}, 52 | Title = {\proglang{R} Graphics}, 53 | Year = 2005} 54 | 55 | @manual{WarnesLeisch05, 56 | Author = {Gregory Warnes and Friedrich Leisch}, 57 | Note = {\proglang{R} package version 1.2.0}, 58 | Title = {\pkg{genetics}: Population Genetics}, 59 | Year = {2005}} 60 | 61 | @article{Lewontin64, 62 | Author = {Lewontin, R.C.}, 63 | Journal = {Genetics}, 64 | Pages = {49--67}, 65 | Title = {The Interaction of Selection and Linkage. I. General Considerations; Heterotic Models}, 66 | Volume = {49}, 67 | Year = {1964}} 68 | 69 | @article{PritchardPrzeworski01, 70 | Author = {Pritchard, J.K. and Przeworski, M.}, 71 | Journal = {The American Journal of Human Genetics}, 72 | Pages = {1--14}, 73 | Title = {Linkage Disequilibrium in Humans: Models and Data}, 74 | Volume = {69}, 75 | Year = {2001}} 76 | 77 | @article{HapMap03, 78 | Author = {{The International HapMap Consortium}}, 79 | Journal = {Nature}, 80 | Pages = {789--796}, 81 | Title = {The International HapMap Project}, 82 | Volume = {426}, 83 | Year = {2003}} 84 | 85 | @article{HapMap05, 86 | Author = {{The International HapMap Consortium}}, 87 | Journal = {Nature}, 88 | Pages = {1299--1320}, 89 | Title = {A Haplotype Map of the Human Genome}, 90 | Volume = {437}, 91 | Year = {2005}} 92 | -------------------------------------------------------------------------------- /man/LDheatmap.addScatterplot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/LDheatmap.addScatterplot.R 3 | \name{LDheatmap.addScatterplot} 4 | \alias{LDheatmap.addScatterplot} 5 | \title{Add a scatter plot to an LDheatmap object} 6 | \usage{ 7 | LDheatmap.addScatterplot(LDheatmap, P, height = 0.2, ylab = NULL, ylim=NULL, 8 | type = "points") 9 | } 10 | \arguments{ 11 | \item{LDheatmap}{An object of class LDheatmap.} 12 | 13 | \item{P}{A vector with the values to be plotted as the y axis.} 14 | 15 | \item{height}{The height of the plot.} 16 | 17 | \item{ylab}{The y axis label.} 18 | 19 | \item{ylim}{The y axis limits.} 20 | 21 | \item{type}{Plot type. Possible values are \code{"points"} (the default), \code{"lines"} or \code{"both"}.} 22 | } 23 | \value{ 24 | An object of class LDheatmap given as an argument, with the \code{grob} 25 | \code{LDheatmapGrob} modified to inclue the \code{"association"} child grob. 26 | } 27 | \description{ 28 | Add a scatter plot to an LDheatmap object. 29 | The x axis is the map of genetic distances of the SNPs. 30 | } 31 | \details{ 32 | The function creates an \code{"association"} \code{grob} and adds it to the \code{LDheatmap} object. 33 | Then it pushes a \code{viewport} and draws the \code{LDheatmapGrob} onto it. 34 | } 35 | \note{ 36 | The function can display at most two scatter plots in the default setting. To add three or more scatter plots 37 | in the same viewport, the user can change the input value \code{"location"} from function \code{constructVP} which is 38 | the function inside the \code{LDheatmap.addScatterplot}. The default \code{"location"} value is 0.03, for adding the 39 | third scatter plot, user needs to set the \code{"location"} to 0.23, where 0.2 units is the height of the scatter plot. 40 | For the fourth scatter plot, set the \code{"location"} to 0.43 etc. 41 | See Examples for usage. 42 | } 43 | \examples{ 44 | # Load the package's data set 45 | data("CEUData") 46 | # Produce an LDheatmap object 47 | MyLDheatmap <- LDheatmap(CEUSNP, genetic.distances = CEUDist, flip = TRUE) 48 | # Generate an arbitrary vector of values to plot 49 | Yvalues <- seq(length = length(MyLDheatmap$genetic.distances), from = 0.01, to = 0.5) 50 | # Add scatter plot 51 | assoc <- LDheatmap.addScatterplot(MyLDheatmap, Yvalues) 52 | ######## Adding three or more scatter plots ######## 53 | # Redefine LDheatmap.addScatterplot() to display the third scatter plot 54 | LDheatmap.addScatterplot_test3 <- function(LDheatmap, P, height=0.2, ylab=NULL, 55 | ylim=NULL, type="points",color,pch) { 56 | if (dim(LDheatmap$LDmatrix)[1] != length(P)) { 57 | print("Length of vector not equal number of SNPs in LDheatmap") 58 | return() 59 | 60 | flip <- !is.null(LDheatmap$flipVP) 61 | vp <- constructVP(LDheatmap$LDheatmapGrob, 0.23, flip) 62 | ...... 63 | return(LDheatmap) 64 | }} 65 | environment(LDheatmap.addScatterplot_test3) <- asNamespace('LDheatmap') 66 | 67 | } 68 | \seealso{ 69 | \code{\link{LDheatmap}} 70 | } 71 | \author{ 72 | Sigal Blay and more 73 | } 74 | \keyword{hplot} 75 | -------------------------------------------------------------------------------- /man/LDheatmap.marks.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/LDheatmap.marks.R 3 | \name{LDheatmap.marks} 4 | \alias{LDheatmap.marks} 5 | \title{Plots a symbol in the centers of cells of the heat map image} 6 | \usage{ 7 | LDheatmap.marks(LDheatmap, i, j = NULL, pch = 20, gp=gpar(...), ...) 8 | } 9 | \arguments{ 10 | \item{LDheatmap}{An object of class \code{"LDheatmap"} 11 | returned by the function \code{\link{LDheatmap}()}.} 12 | 13 | \item{i}{A vector of indices of the first set of SNPs.} 14 | 15 | \item{j}{A vector of indices of the second set of SNPs.} 16 | 17 | \item{pch}{Either an integer value or a single character specifying 18 | the symbol to be plotted. See \code{\link[graphics]{points}()} 19 | for possible values and their corresponding symbols.} 20 | 21 | \item{gp}{Graphical parameters; See \code{\link[grid]{gpar}()}.} 22 | 23 | \item{...}{Graphical parameter settings to be passed on to the \code{\link[grid]{gpar}()} 24 | function.} 25 | } 26 | \value{ 27 | \item{ x }{ The vector of x coordinate(s) of the plotted symbol(s).} 28 | \item{ y }{ The vector of y coordinate(s) of the plotted symbol(s). } 29 | } 30 | \description{ 31 | The function \code{LDheatmap.marks()} is used to plot 32 | a symbol in the centers of cells representing the 33 | pairwise linkage disequilibria of specified pairs of SNPs. 34 | } 35 | \details{ 36 | The lengths of the vectors \code{i} and \code{j} must be the same and 37 | greater than or equal to 1. 38 | If the lengths are greater than 1, the function plots the specified 39 | symbol in the centers of the (i\eqn{\mbox{\textasciicircum}}{^}k, 40 | j\eqn{\mbox{\textasciicircum}}{^}k)-th cells (for k=1,...K; K = 41 | length of the vectors \code{i} and \code{j}), where 42 | i\eqn{\mbox{\textasciicircum}}{^}k and 43 | j\eqn{\mbox{\textasciicircum}}{^}k are 44 | the k-th elements of vectors \code{i} and \code{j}, respectively. 45 | For example, if \code{i=c(1,2)} and \code{j=c(3,5)}, \code{LDheatmap()} 46 | plots a symbol in the centers of the cells representing pairwise 47 | linkage disequilibria between the first and third SNPs and between the 48 | second and fifth SNPs in the genome of interest. Note that the order 49 | of the sets of indices does not matter; for example, 50 | \code{LDheatmap.marks(LDheatmap, i=c(1,2), j=c(3,5))} is equivalent 51 | to \code{LDheatmap.marks(LDheatmap, i=c(3,5), j=c(1,2))}. 52 | } 53 | \section{Warning}{ 54 | By default, \code{LDheatmap.marks()} finds the viewport to draw on from 55 | the \code{LDheatmap} object passed to it as an argument. 56 | However, if \code{LDheatmap()} was called with the option \code{pop=TRUE}, 57 | the resulting \code{LDheatmap} object is not assigned a 58 | viewport. In this case, \code{LDheatmap.marks()} assumes 59 | the user wishes to highlight in the current viewport. 60 | Therefore, if \code{LDheatmap()} 61 | has been called with the option \code{pop=TRUE}, 62 | the user must navigate to the correct viewport 63 | before calling \code{LDheatmap.marks()}. 64 | } 65 | 66 | \examples{ 67 | data(CEUData) 68 | tt <- LDheatmap(CEUSNP, genetic.distances=CEUDist) 69 | LDheatmap.marks(tt, 15, 3, cex=1.6, col="blue") 70 | } 71 | \author{ 72 | Nicholas Lewin-Koh , Ji-Hyung Shin , 73 | Sigal Blay 74 | } 75 | \keyword{aplot} 76 | -------------------------------------------------------------------------------- /src/GT_to_SnpMatrix.cpp: -------------------------------------------------------------------------------- 1 | #include "Rcpp.h" 2 | #include 3 | #include 4 | 5 | using namespace Rcpp; 6 | using namespace std; 7 | 8 | 9 | // testing, first asume phased = T 10 | // [[Rcpp::export]] 11 | S4 GT_to_SnpMatrix (CharacterMatrix GT, bool phased = true) { 12 | 13 | int nrow = GT.ncol(); 14 | int ncol = GT.nrow(); 15 | List GT_dimnames = (Rf_isNull(GT.attr("dimnames")))? List::create(R_NilValue, R_NilValue): GT.attr("dimnames"); 16 | List dimnames = List::create(GT_dimnames[1], GT_dimnames[0]); 17 | 18 | if (!phased) { 19 | 20 | RawMatrix mat(nrow, ncol); 21 | 22 | for (int i = 0; i < nrow; i++) { 23 | for (int j = 0; j < ncol; j++) { 24 | 25 | int num = (GT(j, i)[0] - '0') + (GT(j, i)[2] - '0') + 1; 26 | mat(i,j) = (num > 0 && num < 4)? num: 0; 27 | 28 | } 29 | } 30 | 31 | S4 S("SnpMatrix"); 32 | S.slot(".Data") = mat; 33 | S.attr("dimnames") = dimnames; 34 | 35 | return S; 36 | 37 | } else { 38 | 39 | 40 | RawMatrix mat(2*nrow, ncol); 41 | List dimnamesNew = List::create(R_NilValue, R_NilValue); 42 | 43 | if (!Rf_isNull(dimnames[0])) { 44 | 45 | CharacterVector rowNames = dimnames[0]; 46 | CharacterVector rowNamesNew(2*nrow); 47 | 48 | for (int i = 0; i < nrow; i++) { 49 | 50 | string str1(rowNames[i]); 51 | string str2(rowNames[i]); 52 | rowNamesNew[i*2] = (str1.append(".1")).c_str(); 53 | rowNamesNew[i*2+1] = (str2.append(".2")).c_str(); 54 | 55 | for (int j = 0; j < ncol; j++) { 56 | 57 | int num1 = GT(j, i)[0] - '0'; 58 | int num2 = GT(j, i)[2] - '0'; 59 | 60 | if (num1 == 0) { 61 | mat(i*2, j) = 1; 62 | } else if (num1 == 1) { 63 | mat(i*2, j) = 3; 64 | } else { 65 | mat(i*2, j) = 0; 66 | } 67 | 68 | if (num2 == 0) { 69 | mat(i*2+1, j) = 1; 70 | } else if (num2 == 1) { 71 | mat(i*2+1, j) = 3; 72 | } else { 73 | mat(i*2+1, j) = 0; 74 | } 75 | 76 | } 77 | } 78 | 79 | dimnamesNew[0] = rowNamesNew; 80 | 81 | 82 | } else { 83 | 84 | for (int i = 0; i < nrow; i++) { 85 | for (int j = 0; j < ncol; j++) { 86 | 87 | int num1 = GT(j, i)[0] - '0'; 88 | int num2 = GT(j, i)[2] - '0'; 89 | 90 | if (num1 == 0) { 91 | mat(i*2, j) = 1; 92 | } else if (num1 == 1) { 93 | mat(i*2, j) = 3; 94 | } else { 95 | mat(i*2, j) = 0; 96 | } 97 | 98 | if (num2 == 0) { 99 | mat(i*2+1, j) = 1; 100 | } else if (num2 == 1) { 101 | mat(i*2+1, j) = 3; 102 | } else { 103 | mat(i*2+1, j) = 0; 104 | } 105 | 106 | } 107 | } 108 | } 109 | 110 | if (!Rf_isNull(dimnames[1])) { 111 | dimnamesNew[1] = dimnames[1]; 112 | } 113 | 114 | S4 XS("XSnpMatrix"); 115 | XS.slot("diploid") = LogicalVector(nrow*2, FALSE); 116 | XS.slot(".Data") = mat; 117 | XS.attr("dimnames") = dimnamesNew; 118 | 119 | return XS; 120 | } 121 | } 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /man/LDheatmap.highlight.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/LDheatmap.highlight.R 3 | \name{LDheatmap.highlight} 4 | \alias{LDheatmap.highlight} 5 | \title{Highlight a genetic region in the linkage disequilibrium heat map} 6 | \usage{ 7 | LDheatmap.highlight(LDheatmap, i, j, fill = "NA", col = "black", lwd = 1, 8 | lty = 1,flipOutline=FALSE, crissCross = FALSE) 9 | } 10 | \arguments{ 11 | \item{LDheatmap}{An object of class \code{"LDheatmap"} returned 12 | by the function \code{LDheatmap()}.} 13 | 14 | \item{i}{A numeric value specifying the index of the first 15 | SNP to be in the highlighted region.} 16 | 17 | \item{j}{A numeric value specifying the index of the last SNP, 18 | which must be different from \code{i}, to be in the highlighted region.} 19 | 20 | \item{fill}{Color to fill the highlighted area with.} 21 | 22 | \item{col}{A character string specifying the color of the line 23 | segments defining the boundary of highlighted region; see 24 | \code{\link[graphics]{par}()} for possible values.} 25 | 26 | \item{lwd}{A \emph{positive} number specifying the width of the 27 | boundary segments.} 28 | 29 | \item{lty}{Either an integer or a character string specifying the 30 | line type of the boundary segments; see \code{\link[graphics]{par}()} 31 | for possible values.} 32 | 33 | \item{flipOutline}{A Boolean variable that flips the outlined section 34 | over the diagonal of the heatmap.} 35 | 36 | \item{crissCross}{A Boolean variable that controls whether a contiguous 37 | selection of SNPs are outlined only on their polygonal boundary or at 38 | individual SNP levels.} 39 | } 40 | \value{ 41 | A data frame of the x and y coordinates of points defining the 42 | border of the highlighted area. 43 | } 44 | \description{ 45 | The function \code{LDheatmap.highlight()} is used to highlight a 46 | specified genetic region in the linkage disequilibrium (LD) 47 | heat map drawn with the \code{\link{LDheatmap}()} function. 48 | } 49 | \note{ 50 | The function \code{LDheatmap.highlight()} highlights the cells representing 51 | the pairwise LD for the SNPs located between \code{i}-th and \code{j}-th (inclusive) 52 | SNPs in the genomic region of interest. 53 | The order of indices has no effect on the plot. For example, 54 | \code{LDheatmap.highlight(LDheatmap, i=2, j=4)} is the same as 55 | \code{LDheatmap.highlight(LDheatmap, i=4, j=2)}, which highlights 56 | the cells representing the pairwise LD for the second, 57 | third and fourth SNPs. 58 | } 59 | \section{Warning}{ 60 | By default, \code{LDheatmap.highlight()} finds the viewport to draw on from 61 | the \code{LDheatmap} object passed to it as an argument. 62 | However, if \code{LDheatmap()} was called with the option \code{pop=TRUE}, 63 | the resulting \code{LDheatmap} object is not assigned a 64 | viewport. In this case, \code{LDheatmap.highlight()} assumes 65 | the user wishes to highlight in the current viewport. 66 | Therefore, if \code{LDheatmap()} 67 | has been called with the option \code{pop=TRUE}, 68 | the user must navigate to the correct viewport 69 | before calling \code{LDheatmap.highlight()}. 70 | } 71 | 72 | \examples{ 73 | data(CEUData) 74 | tt <- LDheatmap(CEUSNP, genetic.distances=CEUDist) 75 | LDheatmap.highlight(tt, 3, 8, col="blue", fill="green", lwd=3, flipOutline=FALSE, crissCross=FALSE) 76 | } 77 | \author{ 78 | Nicholas Lewin-Koh 79 | , 80 | Ji-Hyung Shin , Sigal Blay 81 | } 82 | \keyword{aplot} 83 | -------------------------------------------------------------------------------- /docs/pkgdown.js: -------------------------------------------------------------------------------- 1 | /* http://gregfranko.com/blog/jquery-best-practices/ */ 2 | (function($) { 3 | $(function() { 4 | 5 | $("#sidebar") 6 | .stick_in_parent({offset_top: 40}) 7 | .on('sticky_kit:bottom', function(e) { 8 | $(this).parent().css('position', 'static'); 9 | }) 10 | .on('sticky_kit:unbottom', function(e) { 11 | $(this).parent().css('position', 'relative'); 12 | }); 13 | 14 | $('body').scrollspy({ 15 | target: '#sidebar', 16 | offset: 60 17 | }); 18 | 19 | $('[data-toggle="tooltip"]').tooltip(); 20 | 21 | var cur_path = paths(location.pathname); 22 | var links = $("#navbar ul li a"); 23 | var max_length = -1; 24 | var pos = -1; 25 | for (var i = 0; i < links.length; i++) { 26 | if (links[i].getAttribute("href") === "#") 27 | continue; 28 | var path = paths(links[i].pathname); 29 | 30 | var length = prefix_length(cur_path, path); 31 | if (length > max_length) { 32 | max_length = length; 33 | pos = i; 34 | } 35 | } 36 | 37 | // Add class to parent
  • , and enclosing
  • if in dropdown 38 | if (pos >= 0) { 39 | var menu_anchor = $(links[pos]); 40 | menu_anchor.parent().addClass("active"); 41 | menu_anchor.closest("li.dropdown").addClass("active"); 42 | } 43 | }); 44 | 45 | function paths(pathname) { 46 | var pieces = pathname.split("/"); 47 | pieces.shift(); // always starts with / 48 | 49 | var end = pieces[pieces.length - 1]; 50 | if (end === "index.html" || end === "") 51 | pieces.pop(); 52 | return(pieces); 53 | } 54 | 55 | function prefix_length(needle, haystack) { 56 | if (needle.length > haystack.length) 57 | return(0); 58 | 59 | // Special case for length-0 haystack, since for loop won't run 60 | if (haystack.length === 0) { 61 | return(needle.length === 0 ? 1 : 0); 62 | } 63 | 64 | for (var i = 0; i < haystack.length; i++) { 65 | if (needle[i] != haystack[i]) 66 | return(i); 67 | } 68 | 69 | return(haystack.length); 70 | } 71 | 72 | /* Clipboard --------------------------*/ 73 | 74 | function changeTooltipMessage(element, msg) { 75 | var tooltipOriginalTitle=element.getAttribute('data-original-title'); 76 | element.setAttribute('data-original-title', msg); 77 | $(element).tooltip('show'); 78 | element.setAttribute('data-original-title', tooltipOriginalTitle); 79 | } 80 | 81 | if(Clipboard.isSupported()) { 82 | $(document).ready(function() { 83 | var copyButton = ""; 84 | 85 | $(".examples, div.sourceCode").addClass("hasCopyButton"); 86 | 87 | // Insert copy buttons: 88 | $(copyButton).prependTo(".hasCopyButton"); 89 | 90 | // Initialize tooltips: 91 | $('.btn-copy-ex').tooltip({container: 'body'}); 92 | 93 | // Initialize clipboard: 94 | var clipboardBtnCopies = new Clipboard('[data-clipboard-copy]', { 95 | text: function(trigger) { 96 | return trigger.parentNode.textContent; 97 | } 98 | }); 99 | 100 | clipboardBtnCopies.on('success', function(e) { 101 | changeTooltipMessage(e.trigger, 'Copied!'); 102 | e.clearSelection(); 103 | }); 104 | 105 | clipboardBtnCopies.on('error', function() { 106 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 107 | }); 108 | }); 109 | } 110 | })(window.jQuery || window.$) 111 | -------------------------------------------------------------------------------- /R/LDheatmap.addRecombRate.R: -------------------------------------------------------------------------------- 1 | #' @name LDheatmap.addRecombRate 2 | #' @aliases LDheatmap.addRecombRate 3 | #' @title Add recombination rate plot to an LD heat map. 4 | #' @description Retrieve average rates of recombination from the deCODE genetic map from the UCSC 5 | #'Genome Browser and add them to an LDheatmap object. 6 | #' @usage LDheatmap.addRecombRate(LDheatmap, chromosome, genome = NULL, recombRateLocation = 0.02, 7 | #'view = "dense") 8 | #' @param LDheatmap An object of class LDheatmap. 9 | #' @param chromosome A character string that identifies the chromosome. 10 | #' @param genome The genome assembly to use. The default is the most recent human genome assembly on the UCSC Genome Browser. 11 | #' @param recombRateLocation The plot distance from the LD heat map gene map. 12 | #' @param view Display mode. Possible values are \code{"dense"} (the default), \code{"squish"}, 13 | #'\code{"pack"} and \code{"full"}. 14 | #' @return An object of class LDheatmap given as an argument, with the \code{grob} 15 | #'\code{LDheatmapGrob} modified to inclue the \code{"recombRate"} child grob. 16 | #' @references \url{http://genome.ucsc.edu/cgi-bin/hgTrackUi?g=recombRate} 17 | #' @author Sigal Blay 18 | #' @seealso \code{\link{LDheatmap}}, \code{\link{recombRate}} 19 | #' @examples \donttest{ 20 | #'data(GIMAP5.CEU) 21 | #'ll<-LDheatmap(GIMAP5.CEU$snp.data,GIMAP5.CEU$snp.support$Position,flip=TRUE) 22 | #'# Add recombination rate plot 23 | #'ll_recomb <- LDheatmap.addRecombRate(ll, chr="chr7", genome="hg18") 24 | #'} 25 | #' @keywords hplot 26 | #' @export 27 | 28 | 29 | # ldheatmap - Plots measures of pairwise linkage disequilibria for SNPs 30 | # Copyright (C) 2004 J.Shin, S. Blay, N. Lewin-Koh, J.Graham, B.McNeney 31 | 32 | # To cite LDheatmap in publications use: 33 | # Shin J-H, Blay S, McNeney B and Graham J (2006). LDheatmap: An R 34 | # Function for Graphical Display of Pairwise Linkage Disequilibria 35 | # Between Single Nucleotide Polymorphisms. J Stat Soft, 16 Code Snippet 3 36 | 37 | # This program is free software; you can redistribute it and/or modify 38 | # it under the terms of the GNU General Public License as published by 39 | # the Free Software Foundation; either version 2 of the License, or 40 | # (at your option) any later version. 41 | 42 | # This program is distributed in the hope that it will be useful, 43 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 44 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 45 | # GNU General Public License for more details. 46 | 47 | # You should have received a copy of the GNU General Public License 48 | # along with this program; if not, write to the Free Software 49 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 50 | 51 | ########################################################################### 52 | 53 | #__________Add Recomb Rate track from UCSC genome Browser to an LDheatmap_________## 54 | LDheatmap.addRecombRate <- function(LDheatmap, chromosome, genome=NULL, recombRateLocation=0.02, view="dense") { 55 | requireNamespace("grid") 56 | minRange <- min(LDheatmap$genetic.distances) 57 | maxRange <- max(LDheatmap$genetic.distances) 58 | # minRange <- 129000000 59 | # maxRange <- 140000000 60 | 61 | flip <- !is.null(LDheatmap$flipVP) 62 | vp <- constructVP(LDheatmap$LDheatmapGrob, recombRateLocation, flip) 63 | vp$height <- unit(0.06, "npc") 64 | vp$name <- "recombRateVP" 65 | pushViewport(LDheatmap$LDheatmapGrob$vp) # the vps are necessary for the calculation of grobWidth 66 | if (flip) pushViewport(LDheatmap$flipVP) # in the recombRate function 67 | recombRate <- recombRate(minRange, maxRange, chromosome, genome, vp=vp, view) 68 | vp <- recombRate$vp 69 | vpstack <- vp; if(flip) vpstack <- vpStack(LDheatmap$flipVP,vp) 70 | grobT <- editGrob(recombRate, vp=vpstack) 71 | LDheatmap$LDheatmapGrob <-addGrob(LDheatmap$LDheatmapGrob, grobT) 72 | LDheatmap$LDheatmapGrob <- moveTitles(LDheatmap$LDheatmapGrob, vp) 73 | return(LDheatmap) 74 | } 75 | 76 | -------------------------------------------------------------------------------- /R/LDheatmap.addGenes.R: -------------------------------------------------------------------------------- 1 | #' @name LDheatmap.addGenes 2 | #' @aliases LDheatmap.addGenes 3 | #' @title Add gene plot to an LDheatmap object. 4 | #' @description Retrieve genes from the UCSC Genome Browser, generate the genes plot and add it to 5 | #'an LDheatmap object. 6 | #' @usage LDheatmap.addGenes(LDheatmap, chromosome, genome = NULL, genesLocation = 0.02, 7 | #'splice_variants = TRUE, non_coding = TRUE) 8 | #' @param LDheatmap An object of class LDheatmap. 9 | #' @param chromosome A character string that identifies the chromosome. 10 | #' @param genome The genome assembly to use. The default is the most recent human genome assembly on the UCSC genome browser. 11 | #' @param genesLocation The gene plot distance from the LD heat map gene map. 12 | #' @param splice_variants If \code{FALSE}, exclude gene splice variants. 13 | #' @param non_coding If \code{FALSE}, exclude non-coding genes. 14 | #' @details Note: The \code{LDheatmap} object should have a non-NULL \code{genetic.distances} 15 | #'component. Otherwise the gene map will not be placed correctly. 16 | #'The genes are color coded as follows: 17 | #' black -- feature has a corresponding entry in the Protein Data Bank (PDB); 18 | #'dark blue -- transcript has been reviewed or validated by either the RefSeq, SwissProt or CCDS staff; 19 | #'medium blue -- other RefSeq transcripts; and 20 | #'light blue -- non-RefSeq transcripts. 21 | #' 22 | #'For assemblies older than hg18, all genes are plotted in grey. 23 | #' @return An object of class LDheatmap given as an argument, with the \code{grob} 24 | #'\code{LDheatmapGrob} modified to inclue the \code{"transcripts"} child grob. 25 | #' @references \url{http://genome.ucsc.edu/cgi-bin/hgTrackUi?g=knownGene} 26 | #' @author Sigal Blay 27 | #' @seealso \code{\link{LDheatmap}}, \code{\link{plotGenes}} 28 | #' @examples \donttest{ 29 | #'data(GIMAP5.CEU) 30 | #'ll<-LDheatmap(GIMAP5.CEU$snp.data,GIMAP5.CEU$snp.support$Position,flip=TRUE) 31 | #'# Add gene plot 32 | #'llplusgenes <- LDheatmap.addGenes(ll, chr="chr7", genome="hg18") 33 | #'} 34 | #' @keywords hplot 35 | #' @export 36 | 37 | 38 | # ldheatmap - Plots measures of pairwise linkage disequilibria for SNPs 39 | # Copyright (C) 2004 J.Shin, S. Blay, N. Lewin-Koh, J.Graham, B.McNeney 40 | 41 | # To cite LDheatmap in publications use: 42 | # Shin J-H, Blay S, McNeney B and Graham J (2006). LDheatmap: An R 43 | # Function for Graphical Display of Pairwise Linkage Disequilibria 44 | # Between Single Nucleotide Polymorphisms. J Stat Soft, 16 Code Snippet 3 45 | 46 | # This program is free software; you can redistribute it and/or modify 47 | # it under the terms of the GNU General Public License as published by 48 | # the Free Software Foundation; either version 2 of the License, or 49 | # (at your option) any later version. 50 | 51 | # This program is distributed in the hope that it will be useful, 52 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 53 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 54 | # GNU General Public License for more details. 55 | 56 | # You should have received a copy of the GNU General Public License 57 | # along with this program; if not, write to the Free Software 58 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 59 | 60 | ############################################################################ 61 | 62 | 63 | 64 | #_______________________Add genes from UCSC genome Browser to an LDheatmap_____________## 65 | LDheatmap.addGenes <- function(LDheatmap, chromosome, genome=NULL, genesLocation=0.02, splice_variants = TRUE, non_coding = TRUE) { 66 | if(is.null(LDheatmap$genetic.distances)) stop("LDheatmap must have genetic distances") 67 | requireNamespace("grid") 68 | minRange <- min(LDheatmap$genetic.distances) 69 | maxRange <- max(LDheatmap$genetic.distances) 70 | # minRange <- 150124000 #150434000 71 | # maxRange <- 150154477 #150220000 72 | 73 | # gimap5 74 | # minRange <- 149656848 75 | # maxRange <- 150154477 76 | 77 | # a range with a single gene 78 | # minRange <- 149656848 79 | # maxRange <- 149750000 80 | 81 | flip <- !is.null(LDheatmap$flipVP) 82 | vp <- constructVP(LDheatmap$LDheatmapGrob, genesLocation, flip) 83 | pushViewport(LDheatmap$LDheatmapGrob$vp) # the vps are necessary for the calculation of grobWidth 84 | if (flip) pushViewport(LDheatmap$flipVP) # in the plotGenes function 85 | Transcripts <- plotGenes(minRange, maxRange, chromosome, genome, plot_lines_distance=0.04, vp=vp, splice_variants) 86 | vp <- Transcripts$vp 87 | vpstack <- vp; if(flip) vpstack <- vpStack(LDheatmap$flipVP,vp) 88 | grobT <- editGrob(Transcripts, vp=vpstack) 89 | LDheatmap$LDheatmapGrob <-addGrob(LDheatmap$LDheatmapGrob, grobT) 90 | LDheatmap$LDheatmapGrob <- moveTitles(LDheatmap$LDheatmapGrob, vp) 91 | return(LDheatmap) 92 | } 93 | 94 | 95 | -------------------------------------------------------------------------------- /demo/LDheatmap.R: -------------------------------------------------------------------------------- 1 | #GY - permission check 2 | #Load the package's data set 3 | data(CEUData) 4 | #Creates a data frame "CEUSNP" of genotype data and a vector "CEUDist" 5 | #of physical locations of the SNPs 6 | 7 | #### Produce a heat map in a grey color scheme #### 8 | 9 | MyHeatmap <- LDheatmap(CEUSNP, genetic.distances = CEUDist, 10 | color = grey.colors(20)) 11 | 12 | # Prompt the user before starting a new page of graphics output 13 | # and save the original prompt settings in old.prompt. 14 | old.prompt <- devAskNewPage(ask = TRUE) 15 | 16 | # Highlight a certain LD block of interest: 17 | LDheatmap.highlight(MyHeatmap, i = 3, j = 8, col = "black", fill = "grey" ) 18 | # Plot a symbol in the center of the pixel which represents LD between 19 | # the fourth and seventh SNPs: 20 | LDheatmap.marks(MyHeatmap, 4, 7, gp=gpar(cex=2), pch = "*") 21 | 22 | #### Modify the plot by using 'grid.edit' function #### 23 | #Draw a heat map where the SNPs "rs2283092" and "rs6979287" are labelled. 24 | LDheatmap(MyHeatmap, SNP.name = c("rs2283092", "rs6979287")) 25 | 26 | #Find the names of the top-level graphical objects (grobs) on the current display 27 | getNames() 28 | #[1] "ldheatmap" 29 | 30 | # Find the names of the component grobs of "ldheatmap" 31 | childNames(grid.get("ldheatmap")) 32 | #[1] "heatMap" "geneMap" "Key" 33 | 34 | #Find the names of the component grobs of heatMap 35 | childNames(grid.get("heatMap")) 36 | #[1] "heatmap" "title" 37 | 38 | #Find the names of the component grobs of geneMap 39 | childNames(grid.get("geneMap")) 40 | #[1] "diagonal" "segments" "title" "symbols" "SNPnames" 41 | 42 | #Find the names of the component grobs of Key 43 | childNames(grid.get("Key")) 44 | #[1] "colorKey" "title" "labels" "ticks" "box" 45 | 46 | #Change the plotting symbols that identify SNPs rs2283092 and rs6979287 47 | #on the plot to bullets 48 | grid.edit("symbols", pch = 20, gp = gpar(cex = 1)) 49 | 50 | #Change the color of the main title 51 | grid.edit(gPath("ldheatmap", "heatMap", "title"), gp = gpar(col = "red")) 52 | 53 | #Change size of SNP labels 54 | grid.edit(gPath("ldheatmap", "geneMap","SNPnames"), gp = gpar(cex=1.5)) 55 | 56 | #Add a grid of white lines to the plot to separate pairwise LD measures 57 | grid.edit(gPath("ldheatmap", "heatMap", "heatmap"), gp = gpar(col = "white", 58 | lwd = 2)) 59 | 60 | #### Modify a heat map using 'editGrob' function #### 61 | MyHeatmap <- LDheatmap(MyHeatmap, color = grey.colors(20)) 62 | 63 | new.grob <- editGrob(MyHeatmap$LDheatmapGrob, gPath("geneMap", "segments"), 64 | gp=gpar(col="orange")) 65 | 66 | ##Clear the old graphics object from the display before drawing the modified heat map: 67 | grid.newpage() 68 | 69 | grid.draw(new.grob) 70 | # now the colour of line segments connecting the SNP 71 | # positions to the LD heat map has been changed from black to orange. 72 | 73 | #### Draw a resized heat map (in a 'blue-to-red' color scale #### 74 | grid.newpage() 75 | 76 | pushViewport(viewport(width=0.5, height=0.5)) 77 | LDheatmap(MyHeatmap, SNP.name = c("rs2283092", "rs6979287"), newpage=FALSE, 78 | color="blueToRed") 79 | popViewport() 80 | 81 | #### Draw and modify two heat maps on one plot #### 82 | grid.newpage() 83 | 84 | ##Draw and the first heat map on the left half of the graphics device 85 | pushViewport(viewport(x=0, width=0.5, just="left")) 86 | LD1<-LDheatmap(MyHeatmap, color=grey.colors(20), newpage=FALSE, 87 | title="Pairwise LD in grey.colors(20)", 88 | SNP.name="rs6979572", geneMapLabelX=0.6, 89 | geneMapLabelY=0.4, name="ld1") 90 | upViewport() 91 | 92 | ##Draw the second heat map on the right half of the graphics device 93 | pushViewport(viewport(x=1,width=0.5,just="right")) 94 | LD2<-LDheatmap(MyHeatmap, newpage=FALSE, title="Pairwise LD in heat.colors(20)", 95 | SNP.name="rs6979572", geneMapLabelX=0.6, geneMapLabelY=0.4, name="ld2") 96 | upViewport() 97 | 98 | ##Modify the text size of main title of the first heat map. 99 | grid.edit(gPath("ld1", "heatMap","title"), gp=gpar(cex=1.5)) 100 | 101 | ##Modify the text size and color of the SNP label of the second heat map. 102 | grid.edit(gPath("ld2", "geneMap","SNPnames"), gp=gpar(cex=1.5, col="DarkRed")) 103 | 104 | #### Draw a lattice-like plot with heat maps in panels #### 105 | # Load CHBJPTSNP and CHBJPTDist 106 | data(CHBJPTData) 107 | # Make a variable which indicates Chinese vs. Japanese 108 | pop <- factor(c(rep("chinese",45), rep("japanese",45))) 109 | library(lattice) 110 | 111 | xyplot(1:nrow(CHBJPTSNP) ~ 1:nrow(CHBJPTSNP) | pop, 112 | type="n", scales=list(draw=FALSE), xlab="", ylab="", 113 | panel=function(x, y, subscripts,...) { 114 | LDheatmap(CHBJPTSNP[subscripts,], CHBJPTDist, newpage=FALSE) }) 115 | 116 | #Reset the user's setting for prompting on the graphics output 117 | #to the original value before running these example commands. 118 | devAskNewPage(old.prompt) 119 | -------------------------------------------------------------------------------- /R/vcfR2SnpMatrix.R: -------------------------------------------------------------------------------- 1 | #' @name vcfR2SnpMatrix 2 | #' @aliases vcfR2SnpMatrix 3 | #' @title Extract genotype information from a vcfR object 4 | #' @description Convert a \code{\link[vcfR]{vcfR-class}} object into a list composed of genetic distances, subject IDs, and a \code{\link[snpStats]{SnpMatrix-class}}/\code{\link[snpStats]{XSnpMatrix-class}} object. 5 | #' 6 | #' @usage vcfR2SnpMatrix(obj, phased = NULL, subjects = NULL) 7 | #' 8 | #' @param obj An instance or path of the \code{\link[vcfR]{vcfR-class}} object to be processed. 9 | #' 10 | #' @param phased If \code{TRUE} the output genotype data are in the form of a \code{\link[snpStats]{XSnpMatrix-class}} object. Otherwise, they are in the form of a \code{\link[snpStats]{SnpMatrix-class}} object. 11 | #'If it is unspecified, the phasing status will be determined by checking the first entry in the gt slot of the vcfR object. If the first entry is also missing, the value will be set to \code{FALSE}. 12 | #' 13 | #' @param subjects A character or factor containing subject IDs. If supplied, genotype info of only those subjects will be returned. 14 | #'This should be a subset of the sample IDs in the vcfR object. 15 | #' 16 | #' @details 17 | #' In order to let \code{ vcfR2SnpMatrix} function properly, the input \code{\link[vcfR]{vcfR-class}} object is expected to be generated from a valid VCF file which contains only biallelic SNPs and includes a GT section. 18 | #' 19 | #' @return A list which contains the following components: 20 | #' \item{genetic.distances}{ A numeric vector of the reference positions of SNPs. } 21 | #' \item{subjectID}{ A character vector of IDs of the subjects which the returned genotype data belong to. } 22 | #' \item{data}{An object of \code{\link[snpStats]{SnpMatrix-class}}/\code{\link[snpStats]{XSnpMatrix-class}} containing genotype data. } 23 | #' 24 | #'@seealso \code{\link[vcfR]{io_vcfR}}, \code{\link[snpStats]{SnpMatrix-class}}, \code{\link[snpStats]{XSnpMatrix-class}} 25 | #' 26 | #' @examples # Load the vcfR object -- requires vcfR 27 | #' if (requireNamespace("vcfR", quietly = TRUE)) { 28 | #' require(vcfR) 29 | #' data(vcfR_example) 30 | #' vcf <- vcf[8:12,] 31 | #' # Extract needed genotype information 32 | #' alist <- vcfR2SnpMatrix(vcf) 33 | #' 34 | #' # Draw a pairwise LD plot using the extracted data 35 | #' LDheatmap(alist$data, alist$genetic.distance) 36 | #' } 37 | #' 38 | #' @keywords hplot 39 | #' @export 40 | 41 | # ldheatmap - Plots measures of pairwise linkage disequilibria for SNPs 42 | # Copyright (C) 2004 J.Shin, S. Blay, N. Lewin-Koh, J.Graham, B.McNeney 43 | 44 | # To cite LDheatmap in publications use: 45 | # Shin J-H, Blay S, McNeney B and Graham J (2006). LDheatmap: An R 46 | # Function for Graphical Display of Pairwise Linkage Disequilibria 47 | # Between Single Nucleotide Polymorphisms. J Stat Soft, 16 Code Snippet 3 48 | 49 | # This program is free software; you can redistribute it and/or modify 50 | # it under the terms of the GNU General Public License as published by 51 | # the Free Software Foundation; either version 2 of the License, or 52 | # (at your option) any later version. 53 | 54 | # This program is distributed in the hope that it will be useful, 55 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 56 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 57 | # GNU General Public License for more details. 58 | 59 | # You should have received a copy of the GNU General Public License 60 | # along with this program; if not, write to the Free Software 61 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 62 | 63 | ########################################################################### 64 | 65 | vcfR2SnpMatrix <- function(obj, phased = NULL, subjects = NULL) { 66 | 67 | requireNamespace("snpStats") 68 | 69 | # check validity of phased 70 | if (!is.null(phased) & !is.logical(phased)) stop("Invalid input for parameter phased, must be a logical constant or NULL.") 71 | 72 | # extract genetic distances 73 | if ("POS"%in%colnames(obj@fix)) genetic.distance = as.numeric(obj@fix[,"POS"]) 74 | 75 | # extract genotype info 76 | GT <- obj@gt[,!colnames(obj@gt)%in%"FORMAT"] 77 | 78 | # extract subject IDs 79 | subjectID = colnames(GT) 80 | 81 | # subset GT if sample names are provided 82 | if (!is.null(subjects)) { 83 | GT <- GT[,colnames(GT)%in%subjects] 84 | if (ncol(GT) == 0) stop ("could not find entries with the provided sample names") 85 | } 86 | 87 | # extract phasing info if it is not provided 88 | if (is.null(phased)) { 89 | sep <- unlist(strsplit(GT[1,1], ""))[[2]] 90 | if (sep == "|") { 91 | phased <- TRUE 92 | } else if (sep == "/") { 93 | phased <- FALSE 94 | } else { 95 | phased <- FALSE 96 | } 97 | } 98 | 99 | # extract and add snp identifiers 100 | if ("ID"%in%colnames(obj@fix)) rownames(GT) <- obj@fix[,"ID"] 101 | 102 | # convert GT to SnpMatrix if phased is FALSE, else convert to XSnpMatrix 103 | mat <- GT_to_SnpMatrix(GT, phased) 104 | 105 | 106 | return(list(genetic.distances = genetic.distance, subjectID = subjectID, data = mat)) 107 | 108 | } -------------------------------------------------------------------------------- /docs/pkgdown.css: -------------------------------------------------------------------------------- 1 | /* Sticky footer */ 2 | 3 | /** 4 | * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ 5 | * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css 6 | * 7 | * .Site -> body > .container 8 | * .Site-content -> body > .container .row 9 | * .footer -> footer 10 | * 11 | * Key idea seems to be to ensure that .container and __all its parents__ 12 | * have height set to 100% 13 | * 14 | */ 15 | 16 | html, body { 17 | height: 100%; 18 | } 19 | 20 | body > .container { 21 | display: flex; 22 | height: 100%; 23 | flex-direction: column; 24 | 25 | padding-top: 60px; 26 | } 27 | 28 | body > .container .row { 29 | flex: 1 0 auto; 30 | } 31 | 32 | footer { 33 | margin-top: 45px; 34 | padding: 35px 0 36px; 35 | border-top: 1px solid #e5e5e5; 36 | color: #666; 37 | display: flex; 38 | flex-shrink: 0; 39 | } 40 | footer p { 41 | margin-bottom: 0; 42 | } 43 | footer div { 44 | flex: 1; 45 | } 46 | footer .pkgdown { 47 | text-align: right; 48 | } 49 | footer p { 50 | margin-bottom: 0; 51 | } 52 | 53 | img.icon { 54 | float: right; 55 | } 56 | 57 | img { 58 | max-width: 100%; 59 | } 60 | 61 | /* Typographic tweaking ---------------------------------*/ 62 | 63 | .contents h1.page-header { 64 | margin-top: calc(-60px + 1em); 65 | } 66 | 67 | /* Section anchors ---------------------------------*/ 68 | 69 | a.anchor { 70 | margin-left: -30px; 71 | display:inline-block; 72 | width: 30px; 73 | height: 30px; 74 | visibility: hidden; 75 | 76 | background-image: url(./link.svg); 77 | background-repeat: no-repeat; 78 | background-size: 20px 20px; 79 | background-position: center center; 80 | } 81 | 82 | .hasAnchor:hover a.anchor { 83 | visibility: visible; 84 | } 85 | 86 | @media (max-width: 767px) { 87 | .hasAnchor:hover a.anchor { 88 | visibility: hidden; 89 | } 90 | } 91 | 92 | 93 | /* Fixes for fixed navbar --------------------------*/ 94 | 95 | .contents h1, .contents h2, .contents h3, .contents h4 { 96 | padding-top: 60px; 97 | margin-top: -40px; 98 | } 99 | 100 | /* Static header placement on mobile devices */ 101 | @media (max-width: 767px) { 102 | .navbar-fixed-top { 103 | position: absolute; 104 | } 105 | .navbar { 106 | padding: 0; 107 | } 108 | } 109 | 110 | 111 | /* Sidebar --------------------------*/ 112 | 113 | #sidebar { 114 | margin-top: 30px; 115 | } 116 | #sidebar h2 { 117 | font-size: 1.5em; 118 | margin-top: 1em; 119 | } 120 | 121 | #sidebar h2:first-child { 122 | margin-top: 0; 123 | } 124 | 125 | #sidebar .list-unstyled li { 126 | margin-bottom: 0.5em; 127 | } 128 | 129 | .orcid { 130 | height: 16px; 131 | vertical-align: middle; 132 | } 133 | 134 | /* Reference index & topics ----------------------------------------------- */ 135 | 136 | .ref-index th {font-weight: normal;} 137 | 138 | .ref-index td {vertical-align: top;} 139 | .ref-index .alias {width: 40%;} 140 | .ref-index .title {width: 60%;} 141 | 142 | .ref-index .alias {width: 40%;} 143 | .ref-index .title {width: 60%;} 144 | 145 | .ref-arguments th {text-align: right; padding-right: 10px;} 146 | .ref-arguments th, .ref-arguments td {vertical-align: top;} 147 | .ref-arguments .name {width: 20%;} 148 | .ref-arguments .desc {width: 80%;} 149 | 150 | /* Nice scrolling for wide elements --------------------------------------- */ 151 | 152 | table { 153 | display: block; 154 | overflow: auto; 155 | } 156 | 157 | /* Syntax highlighting ---------------------------------------------------- */ 158 | 159 | pre { 160 | word-wrap: normal; 161 | word-break: normal; 162 | border: 1px solid #eee; 163 | } 164 | 165 | pre, code { 166 | background-color: #f8f8f8; 167 | color: #333; 168 | } 169 | 170 | pre code { 171 | overflow: auto; 172 | word-wrap: normal; 173 | white-space: pre; 174 | } 175 | 176 | pre .img { 177 | margin: 5px 0; 178 | } 179 | 180 | pre .img img { 181 | background-color: #fff; 182 | display: block; 183 | height: auto; 184 | } 185 | 186 | code a, pre a { 187 | color: #375f84; 188 | } 189 | 190 | a.sourceLine:hover { 191 | text-decoration: none; 192 | } 193 | 194 | .fl {color: #1514b5;} 195 | .fu {color: #000000;} /* function */ 196 | .ch,.st {color: #036a07;} /* string */ 197 | .kw {color: #264D66;} /* keyword */ 198 | .co {color: #888888;} /* comment */ 199 | 200 | .message { color: black; font-weight: bolder;} 201 | .error { color: orange; font-weight: bolder;} 202 | .warning { color: #6A0366; font-weight: bolder;} 203 | 204 | /* Clipboard --------------------------*/ 205 | 206 | .hasCopyButton { 207 | position: relative; 208 | } 209 | 210 | .btn-copy-ex { 211 | position: absolute; 212 | right: 0; 213 | top: 0; 214 | visibility: hidden; 215 | } 216 | 217 | .hasCopyButton:hover button.btn-copy-ex { 218 | visibility: visible; 219 | } 220 | 221 | /* mark.js ----------------------------*/ 222 | 223 | mark { 224 | background-color: rgba(255, 255, 51, 0.5); 225 | border-bottom: 2px solid rgba(255, 153, 51, 0.3); 226 | padding: 1px; 227 | } 228 | 229 | /* vertical spacing after htmlwidgets */ 230 | .html-widget { 231 | margin-bottom: 10px; 232 | } 233 | -------------------------------------------------------------------------------- /docs/articles/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Articles • LDheatmap 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 47 | 48 | 49 | 50 | 51 | 52 |
    53 |
    54 | 118 | 119 | 120 |
    121 | 122 |
    123 |
    124 | 127 | 128 |
    129 |

    All vignettes

    130 |

    131 | 132 | 135 |
    136 |
    137 |
    138 | 139 |
    140 | 143 | 144 |
    145 |

    Site built with pkgdown.

    146 |
    147 | 148 |
    149 |
    150 | 151 | 152 | 153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /docs/reference/LDheatmap-internal.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Internal LDheatmap functions and data files — LDheatmap-internal • LDheatmap 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 49 | 50 | 51 | 52 | 53 | 54 |
    55 |
    56 | 120 | 121 | 122 |
    123 | 124 |
    125 |
    126 | 131 | 132 |
    133 | 134 |

    Internal LDheatmap functions.

    135 | 136 |
    137 | 138 | 139 |

    Details

    140 | 141 |

    These are not to be called by the user or are undocumented.

    142 | 143 | 144 |
    145 | 153 |
    154 | 155 |
    156 | 159 | 160 |
    161 |

    Site built with pkgdown.

    162 |
    163 | 164 |
    165 |
    166 | 167 | 168 | 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /data-raw/hapmapCEU.txt: -------------------------------------------------------------------------------- 1 | "rs4615512" "rs2283089" "rs1894731" "rs2283092" "rs2283093" "rs6978939" "rs6979287" "rs6979572" "rs2283094" "rs2283095" "rs6467111" "rs1111183" "rs2237789" "rs2299531" "rs2299532" 2 | "distance" "126273659" "126274467" "126275007" "126275550" "126275720" "126276105" "126276310" "126276415" "126276827" "126276946" "126279350" "126281163" "126281542" "126282535" "126282556" 3 | "1" "T/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/T" "C/T" "A/A" "T/C" "A/T" 4 | "2" "T/C" "C/T" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/T" "C/T" "A/A" "T/C" "A/T" 5 | "3" "T/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/C" "C/T" "A/A" "T/C" "A/T" 6 | "4" "NA" "C/C" "A/G" "T/C" "C/T" "T/G" "T/G" "T/A" "C/T" "C/T" "C/C" "C/C" "A/G" "NA" "A/A" 7 | "5" "T/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/C" "C/T" "A/A" "T/C" "A/T" 8 | "6" "T/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/C" "C/C" "A/A" "T/T" "A/A" 9 | "7" "NA" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/T" "C/T" "A/A" "T/C" "A/T" 10 | "8" "T/T" "C/C" "A/G" "T/C" "C/T" "T/G" "T/G" "T/A" "C/C" "C/T" "C/C" "C/T" "A/G" "T/C" "A/T" 11 | "9" "C/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "T/T" "C/C" "C/T" "C/C" "A/A" "T/T" "A/A" 12 | "10" "T/T" "C/T" "G/G" "C/C" "C/T" "G/G" "G/G" "T/A" "C/T" "C/T" "C/T" "C/C" "A/G" "NA" "A/A" 13 | "11" "T/T" "C/C" "A/G" "T/C" "C/T" "T/G" "T/G" "T/A" "C/C" "C/T" "C/C" "C/T" "A/G" "NA" "A/T" 14 | "12" "T/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/C" "C/T" "A/A" "T/C" "A/T" 15 | "13" "T/T" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/C" "C/C" "C/C" "T/T" "A/A" "C/C" "T/T" 16 | "14" "T/C" "C/C" "A/G" "T/C" "C/T" "T/G" "T/G" "T/A" "C/T" "C/T" "C/C" "C/C" "A/G" "T/T" "A/A" 17 | "15" "T/T" "C/C" "A/G" "T/C" "C/T" "T/G" "T/G" "T/A" "C/C" "C/T" "C/T" "C/T" "A/G" "T/C" "A/T" 18 | "16" "C/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "T/T" "C/C" "C/C" "C/C" "A/A" "T/T" "A/A" 19 | "17" "C/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "T/T" "C/C" "C/T" "C/C" "A/A" "T/T" "A/A" 20 | "18" "T/C" "C/C" "A/G" "T/C" "C/T" "T/G" "T/G" "T/A" "C/T" "C/T" "C/C" "C/C" "A/G" "T/T" "A/A" 21 | "19" "C/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "T/T" "C/C" "T/T" "C/C" "A/A" "T/T" "A/A" 22 | "20" "T/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/C" "C/T" "A/A" "T/C" "A/T" 23 | "21" "NA" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/C" "C/C" "C/C" "T/T" "A/A" "NA" "T/T" 24 | "22" "T/T" "C/T" "A/G" "T/C" "C/C" "T/G" "T/G" "T/T" "C/T" "C/C" "C/T" "C/T" "A/A" "T/C" "A/T" 25 | "23" "T/C" "T/T" "A/G" "T/C" "C/C" "T/G" "T/G" "T/T" "T/T" "C/C" "T/T" "C/C" "A/A" "T/T" "A/A" 26 | "24" "T/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/C" "C/C" "A/A" "T/T" "A/A" 27 | "25" "T/T" "C/C" "A/G" "T/C" "C/T" "T/G" "T/G" "T/A" "C/C" "C/T" "C/C" "C/T" "A/G" "T/C" "A/T" 28 | "26" "T/T" "C/C" "A/G" "T/C" "C/T" "T/G" "T/G" "T/A" "C/C" "C/T" "C/C" "C/T" "A/G" "T/C" "A/T" 29 | "27" "T/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/C" "C/T" "A/A" "T/C" "A/T" 30 | "28" "T/T" "C/C" "G/G" "C/C" "T/T" "G/G" "G/G" "A/A" "C/C" "T/T" "C/C" "C/C" "G/G" "T/T" "A/A" 31 | "29" "NA" "C/T" "A/G" "T/C" "C/T" "T/G" "T/G" "T/A" "C/T" "C/T" "C/T" "C/C" "A/G" "NA" "A/A" 32 | "30" "T/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/T" "C/T" "A/A" "T/C" "A/T" 33 | "31" "T/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/C" "C/T" "A/A" "T/C" "A/T" 34 | "32" "C/C" "C/T" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "T/T" "C/C" "C/T" "C/C" "A/A" "T/T" "A/A" 35 | "33" "T/T" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/C" "C/C" "C/C" "T/T" "A/A" "C/C" "T/T" 36 | "34" "T/C" "C/C" "A/G" "T/C" "C/T" "T/G" "T/G" "T/A" "C/T" "C/T" "C/T" "C/C" "A/G" "T/T" "A/A" 37 | "35" "T/T" "C/C" "A/G" "T/C" "C/T" "T/G" "T/G" "T/A" "C/C" "C/T" "C/C" "C/T" "A/G" "T/C" "A/T" 38 | "36" "T/T" "C/C" "G/G" "C/C" "T/T" "G/G" "G/G" "A/A" "C/C" "T/T" "C/C" "C/C" "G/G" "T/T" "A/A" 39 | "37" "T/T" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/C" "C/C" "C/C" "C/T" "A/A" "T/C" "A/T" 40 | "38" "C/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "T/T" "C/C" "C/C" "C/C" "A/A" "T/T" "A/A" 41 | "39" "T/T" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/C" "C/C" "C/C" "T/T" "A/A" "C/C" "T/T" 42 | "40" "T/T" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/C" "C/C" "C/C" "T/T" "A/A" "C/C" "T/T" 43 | "41" "C/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "T/T" "C/C" "C/C" "C/C" "A/A" "T/T" "A/A" 44 | "42" "C/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "T/T" "C/C" "C/C" "C/C" "A/A" "T/T" "A/A" 45 | "43" "T/T" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/C" "C/C" "C/C" "C/T" "A/A" "T/C" "A/T" 46 | "44" "NA" "C/C" "A/G" "T/C" "C/T" "T/G" "T/G" "T/T" "C/T" "C/C" "C/C" "C/T" "A/A" "T/C" "A/T" 47 | "45" "NA" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/T" "C/C" "A/A" "T/T" "A/A" 48 | "46" "T/T" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/C" "C/C" "C/C" "C/T" "A/A" "T/C" "A/T" 49 | "47" "T/T" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/C" "C/C" "C/C" "T/T" "A/A" "C/C" "T/T" 50 | "48" "T/C" "C/C" "A/G" "T/C" "C/T" "T/G" "G/G" "T/A" "C/T" "C/T" "C/T" "C/C" "A/G" "NA" "A/A" 51 | "49" "T/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/C" "C/T" "A/A" "T/C" "A/T" 52 | "50" "T/T" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/C" "C/C" "C/C" "T/T" "A/A" "C/C" "T/T" 53 | "51" "T/C" "C/T" "A/G" "T/C" "C/C" "T/G" "T/G" "T/T" "T/T" "C/C" "C/T" "C/C" "A/A" "T/T" "A/A" 54 | "52" "NA" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/T" "C/T" "A/A" "T/C" "A/T" 55 | "53" "T/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/C" "C/T" "A/A" "T/C" "A/T" 56 | "54" "T/C" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/T" "C/C" "C/T" "C/T" "A/A" "T/C" "A/T" 57 | "55" "T/T" "C/T" "A/G" "T/C" "C/C" "T/G" "T/G" "T/T" "C/T" "C/C" "C/T" "C/T" "A/A" "T/C" "A/T" 58 | "56" "C/C" "C/T" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "T/T" "C/C" "C/T" "C/C" "A/A" "T/T" "A/A" 59 | "57" "T/T" "C/C" "A/G" "T/C" "C/T" "T/G" "T/G" "T/A" "C/C" "C/T" "C/C" "C/T" "A/G" "T/C" "A/T" 60 | "58" "NA" "C/C" "A/G" "T/C" "C/T" "T/G" "T/G" "T/A" "C/C" "C/T" "C/C" "C/T" "A/G" "NA" "A/T" 61 | "59" "T/T" "C/C" "A/A" "T/T" "C/C" "T/T" "T/T" "T/T" "C/C" "C/C" "C/C" "T/T" "A/A" "C/C" "T/T" 62 | "60" "T/C" "C/C" "A/G" "T/C" "C/T" "T/G" "T/G" "T/A" "C/T" "C/T" "C/T" "C/C" "A/G" "NA" "A/A" 63 | -------------------------------------------------------------------------------- /R/LDheatmap.marks.R: -------------------------------------------------------------------------------- 1 | #' @name LDheatmap.marks 2 | #' @aliases LDheatmap.marks 3 | #' @title Plots a symbol in the centers of cells of the heat map image 4 | #' @description The function \code{LDheatmap.marks()} is used to plot 5 | #'a symbol in the centers of cells representing the 6 | #'pairwise linkage disequilibria of specified pairs of SNPs. 7 | #' @usage LDheatmap.marks(LDheatmap, i, j = NULL, pch = 20, gp=gpar(...), ...) 8 | #' @param LDheatmap An object of class \code{"LDheatmap"} 9 | #'returned by the function \code{\link{LDheatmap}()}. 10 | #' @param i A vector of indices of the first set of SNPs. 11 | #' @param j A vector of indices of the second set of SNPs. 12 | #' @param pch Either an integer value or a single character specifying 13 | #'the symbol to be plotted. See \code{\link[graphics]{points}()} 14 | #'for possible values and their corresponding symbols. 15 | #' @param gp Graphical parameters; See \code{\link[grid]{gpar}()}. 16 | #' @param ... Graphical parameter settings to be passed on to the \code{\link[grid]{gpar}()} 17 | #'function. 18 | #' @return \item{ x }{ The vector of x coordinate(s) of the plotted symbol(s).} 19 | #' \item{ y }{ The vector of y coordinate(s) of the plotted symbol(s). } 20 | #' @details The lengths of the vectors \code{i} and \code{j} must be the same and 21 | #'greater than or equal to 1. 22 | #'If the lengths are greater than 1, the function plots the specified 23 | #'symbol in the centers of the (i\eqn{\mbox{\textasciicircum}}{^}k, 24 | #' j\eqn{\mbox{\textasciicircum}}{^}k)-th cells (for k=1,...K; K = 25 | #' length of the vectors \code{i} and \code{j}), where 26 | #'i\eqn{\mbox{\textasciicircum}}{^}k and 27 | #'j\eqn{\mbox{\textasciicircum}}{^}k are 28 | #'the k-th elements of vectors \code{i} and \code{j}, respectively. 29 | #'For example, if \code{i=c(1,2)} and \code{j=c(3,5)}, \code{LDheatmap()} 30 | #'plots a symbol in the centers of the cells representing pairwise 31 | #'linkage disequilibria between the first and third SNPs and between the 32 | #'second and fifth SNPs in the genome of interest. Note that the order 33 | #'of the sets of indices does not matter; for example, 34 | #'\code{LDheatmap.marks(LDheatmap, i=c(1,2), j=c(3,5))} is equivalent 35 | #'to \code{LDheatmap.marks(LDheatmap, i=c(3,5), j=c(1,2))}. 36 | #' @section Warning: By default, \code{LDheatmap.marks()} finds the viewport to draw on from 37 | #'the \code{LDheatmap} object passed to it as an argument. 38 | #'However, if \code{LDheatmap()} was called with the option \code{pop=TRUE}, 39 | #'the resulting \code{LDheatmap} object is not assigned a 40 | #'viewport. In this case, \code{LDheatmap.marks()} assumes 41 | #'the user wishes to highlight in the current viewport. 42 | #'Therefore, if \code{LDheatmap()} 43 | #'has been called with the option \code{pop=TRUE}, 44 | #'the user must navigate to the correct viewport 45 | #'before calling \code{LDheatmap.marks()}. 46 | #' @author Nicholas Lewin-Koh , Ji-Hyung Shin , 47 | #'Sigal Blay 48 | #' @examples data(CEUData) 49 | #'tt <- LDheatmap(CEUSNP, genetic.distances=CEUDist) 50 | #'LDheatmap.marks(tt, 15, 3, cex=1.6, col="blue") 51 | #' @keywords aplot 52 | #' @export 53 | 54 | # ldheatmap - Plots measures of pairwise linkage disequilibria for SNPs 55 | # Copyright (C) 2004 J.Shin, S. Blay, N. Lewin-Koh, J.Graham, B.McNeney 56 | 57 | # To cite LDheatmap in publications use: 58 | # Shin J-H, Blay S, McNeney B and Graham J (2006). LDheatmap: An R 59 | # Function for Graphical Display of Pairwise Linkage Disequilibria 60 | # Between Single Nucleotide Polymorphisms. J Stat Soft, 16 Code Snippet 3 61 | 62 | # This program is free software; you can redistribute it and/or modify 63 | # it under the terms of the GNU General Public License as published by 64 | # the Free Software Foundation; either version 2 of the License, or 65 | # (at your option) any later version. 66 | 67 | # This program is distributed in the hope that it will be useful, 68 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 69 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 70 | # GNU General Public License for more details. 71 | 72 | # You should have received a copy of the GNU General Public License 73 | # along with this program; if not, write to the Free Software 74 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 75 | 76 | ########################################################################### 77 | 78 | 79 | 80 | #_______________________Add marks to heatmap__________________________________## 81 | # Adds a symbol to the i,jth cell of the heatmap. 82 | # Does this work when flip=TRUE? 83 | # The default is to add a symbol to the diagonal (j=i). 84 | # i and j can be vectors. 85 | LDheatmap.marks <- function(LDheatmap, i, j=NULL, pch=20, gp=gpar(...), ...){ 86 | requireNamespace("grid") 87 | nSNP <- dim(LDheatmap$LDmatrix)[1] 88 | if(is.null(j)) j<-i 89 | ind <- i>j 90 | if(any(ind)){ 91 | ind <- as.numeric(ind) 92 | ind[ind>0] <- i[ind>0] 93 | i[ind>0] <- j[ind>0] 94 | j[ind>0] <- ind[ind>0] 95 | } 96 | pts<-list(x=(i-0.5)*1/nSNP,y=(j-0.5)*1/nSNP) 97 | if(!is.null(LDheatmap$flipVP)) pts<-list(x=(j-0.5)*1/nSNP,y=(i-0.5)*1/nSNP) 98 | heatmap.vp <- LDheatmap$heatmapVP$name 99 | #If heatmap.vp is on the grid display list, i.e., it is included in the 100 | #returned value of current.vpTree(), a[1] <- 1 else a[1] <- NA 101 | a <- grep(paste("[", heatmap.vp, "]", sep=""), as.character(current.vpTree()), fixed=TRUE) 102 | if(!is.na(a[1])) seekViewport(heatmap.vp) 103 | else pushViewport(LDheatmap$heatmapVP) 104 | if (!is.null(LDheatmap$flipVP)) pushViewport(LDheatmap$flipVP) 105 | Symbols <- pointsGrob(pts$x, pts$y, pch=pch, gp=gp, name="symbols") 106 | symbols <- gTree(children=gList(Symbols), name="Symbols", cl="symbols") 107 | grid.draw(symbols) 108 | if(!is.na(a[1])) upViewport(0) #back to the root viewport 109 | else popViewport() 110 | invisible(pts) 111 | } 112 | 113 | 114 | -------------------------------------------------------------------------------- /R/LDheatmap.addScatterplot.R: -------------------------------------------------------------------------------- 1 | #' @name LDheatmap.addScatterplot 2 | #' @aliases LDheatmap.addScatterplot 3 | #' @title Add a scatter plot to an LDheatmap object 4 | #' @description Add a scatter plot to an LDheatmap object. 5 | #'The x axis is the map of genetic distances of the SNPs. 6 | #' @usage LDheatmap.addScatterplot(LDheatmap, P, height = 0.2, ylab = NULL, ylim=NULL, 7 | #'type = "points") 8 | #' @param LDheatmap An object of class LDheatmap. 9 | #' @param P A vector with the values to be plotted as the y axis. 10 | #' @param height The height of the plot. 11 | #' @param ylab The y axis label. 12 | #' @param ylim The y axis limits. 13 | #' @param type Plot type. Possible values are \code{"points"} (the default), \code{"lines"} or \code{"both"}. 14 | #' @details The function creates an \code{"association"} \code{grob} and adds it to the \code{LDheatmap} object. 15 | #'Then it pushes a \code{viewport} and draws the \code{LDheatmapGrob} onto it. 16 | #' @return An object of class LDheatmap given as an argument, with the \code{grob} 17 | #'\code{LDheatmapGrob} modified to inclue the \code{"association"} child grob. 18 | #' @note The function can display at most two scatter plots in the default setting. To add three or more scatter plots 19 | #'in the same viewport, the user can change the input value \code{"location"} from function \code{constructVP} which is 20 | #'the function inside the \code{LDheatmap.addScatterplot}. The default \code{"location"} value is 0.03, for adding the 21 | #'third scatter plot, user needs to set the \code{"location"} to 0.23, where 0.2 units is the height of the scatter plot. 22 | #'For the fourth scatter plot, set the \code{"location"} to 0.43 etc. 23 | #'See Examples for usage. 24 | #' @author Sigal Blay and more 25 | #' @seealso \code{\link{LDheatmap}} 26 | #' @examples # Load the package's data set 27 | #'data("CEUData") 28 | #'# Produce an LDheatmap object 29 | #'MyLDheatmap <- LDheatmap(CEUSNP, genetic.distances = CEUDist, flip = TRUE) 30 | #'# Generate an arbitrary vector of values to plot 31 | #'Yvalues <- seq(length = length(MyLDheatmap$genetic.distances), from = 0.01, to = 0.5) 32 | #'# Add scatter plot 33 | #'assoc <- LDheatmap.addScatterplot(MyLDheatmap, Yvalues) 34 | #'######## Adding three or more scatter plots ######## 35 | #'# Redefine LDheatmap.addScatterplot() to display the third scatter plot 36 | #'LDheatmap.addScatterplot_test3 <- function(LDheatmap, P, height=0.2, ylab=NULL, 37 | #'ylim=NULL, type="points",color,pch) { 38 | #'if (dim(LDheatmap$LDmatrix)[1] != length(P)) { 39 | #'print("Length of vector not equal number of SNPs in LDheatmap") 40 | #'return() 41 | #' 42 | #'flip <- !is.null(LDheatmap$flipVP) 43 | #'vp <- constructVP(LDheatmap$LDheatmapGrob, 0.23, flip) 44 | #'...... 45 | #'return(LDheatmap) 46 | #'}} 47 | #'environment(LDheatmap.addScatterplot_test3) <- asNamespace('LDheatmap') 48 | #' 49 | #' @keywords hplot 50 | #' @export 51 | 52 | 53 | # LDheatmap - Plots measures of pairwise linkage disequilibria for SNPs 54 | # Copyright (C) 2004 J.Shin, S. Blay, N. Lewin-Koh, J.Graham, B.McNeney 55 | 56 | # To cite LDheatmap in publications use: 57 | # Shin J-H, Blay S, McNeney B and Graham J (2006). LDheatmap: An R 58 | # Function for Graphical Display of Pairwise Linkage Disequilibria 59 | # Between Single Nucleotide Polymorphisms. J Stat Soft, 16 Code Snippet 3 60 | 61 | # This program is free software; you can redistribute it and/or modify 62 | # it under the terms of the GNU General Public License as published by 63 | # the Free Software Foundation; either version 2 of the License, or 64 | # (at your option) any later version. 65 | 66 | # This program is distributed in the hope that it will be useful, 67 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 68 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 69 | # GNU General Public License for more details. 70 | 71 | # You should have received a copy of the GNU General Public License 72 | # along with this program; if not, write to the Free Software 73 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 74 | 75 | ########################################################################### 76 | 77 | 78 | #______________________________________Add Scatter Plot________________________________## 79 | LDheatmap.addScatterplot <- function(LDheatmap, P, height=0.2, ylab=NULL, ylim=NULL, type="points") { 80 | requireNamespace("grid") 81 | if (dim(LDheatmap$LDmatrix)[1] != length(P) ) { 82 | print ("Length of vector not equal number of SNPs in LDheatmap") 83 | return() 84 | } 85 | 86 | flip <- !is.null(LDheatmap$flipVP) 87 | vp <- constructVP(LDheatmap$LDheatmapGrob, 0.03, flip) 88 | vp$height <- unit(height, "npc") 89 | vp$name <- "associationVP" 90 | if(is.null(ylim)) ylim <- c(floor(min(P)), ceiling(max(P))) 91 | vp$yscale <- ylim 92 | vp$xscale <- c(min(LDheatmap$genetic.distances), max(LDheatmap$genetic.distances)) 93 | xaxis <- linesGrob(x=vp$xscale, y=0, default.units="native", name="xaxis") 94 | yaxis <- linesGrob(x=min(LDheatmap$genetic.distances), y=vp$yscale, default.units="native", 95 | name="yaxis") 96 | yaxisT <- yaxisGrob(name="yaxis_ticks", gp=gpar(fontsize=7)) 97 | ylab <- textGrob(ylab, rot=90, gp=gpar(fontsize=9), name="yaxis_title", 98 | x=unit(min(LDheatmap$genetic.distances), "native")- unit(10, "millimeters")) 99 | vpstack <- vp; if(flip) vpstack <- vpStack(LDheatmap$flipVP,vp) 100 | association <- gTree(children=gList(xaxis, yaxis, yaxisT, ylab), name="association", vp=vpstack) 101 | if (type=="points" || type == "both") { 102 | graph_points <- pointsGrob(LDheatmap$genetic.distances, P, size=unit(2, "millimeters"), 103 | name="points") 104 | association <- addGrob(association, graph_points) 105 | } 106 | if (type=="lines" || type == "both") { 107 | graph_lines <- linesGrob(LDheatmap$genetic.distances, P, default.units="native", name="lines") 108 | association <- addGrob(association, graph_lines) 109 | } 110 | LDheatmap$LDheatmapGrob <- addGrob(LDheatmap$LDheatmapGrob, association) 111 | LDheatmap$LDheatmapGrob <- moveTitles(LDheatmap$LDheatmapGrob, vp) 112 | return(LDheatmap) 113 | } 114 | 115 | 116 | -------------------------------------------------------------------------------- /inst/ChangeLog: -------------------------------------------------------------------------------- 1 | 0.9-1 2 | * bug-fix: when flip=TRUE and SNP.name not null, the gene map was being 3 | plotted over the heatmap. Thanks to Martin, Chia-Hsin Liu for reporting 4 | the bug 5 | 6 | 0.9 7 | * Renumber version to prepare for release of a version 1.0 8 | 9 | 0.3 10 | * Added arguments 'flip', 'text' to LDheatmap(). 11 | * Added functions LDheatmap.plotGenes, plotGenes, LDheatmap.recombRate, 12 | recombRate, LDheatmap.addAssociation. 13 | * Added internal functions constructVP, drawLDheatmapGrob, moveTitles. 14 | 15 | 0.2-9 16 | * data/datalist: Took care of the warning message related to undocumented data sets 17 | 18 | 0.2-8 19 | * Missing links in LDheatmap.Rd were taken care of. 20 | * Replace grid.prompt() with devAskNewPage() to fix the Warning Message 21 | given when the 'demo' is running. 22 | 23 | 0.2-7 24 | * Change lower.tri(draw=T) to lower.tri(draw=TRUE) in LDheatmap.R. 25 | * Replace the deprecated grid.prompt() function with devAskNewPage() for 26 | the Example in the LDheatmap fumction documentation (LDheatmap.Rd). 27 | 28 | 0.2-6 29 | * Added "See LDheatmap vignette for details." to the Details section. 30 | 31 | 0.2-5 32 | * 'datalist': "CEUData" and "CHBJPTData" added to fix the 33 | Warning Message. 34 | 35 | 0.2-4 36 | * Added CITATION file to give information to the users how to cite the 37 | LDheatmap Code Snippet. 38 | * LDheatmap.Rd: added ``references" section. 39 | * LDheatmap(): removed `recording' argument from the functions: 40 | preDrawDetails.ldheatmap(), postDrawDetails.ldheatmap(), 41 | preDrawDetails.symbols() and postDrawDetails.symbols(). 42 | 43 | 0.2-3 44 | 45 | demo(LDheatmap) 46 | Revise the examples so that they correspond to the ones in the 47 | documentation of LDheatmap() function. 48 | 49 | 0.2-2 50 | 51 | LDheatmap(): 52 | * Added argument 'pop' to control whether or not the heatmap viewport 53 | is popped after drawing. The default is FALSE. 54 | * Added argument 'vp.name' specifying the name of heatmap viewport. 55 | * Now when SNP.name is provided and add.map=FALSE, the genetic map is not 56 | drawn but the SNP names provided are marked on the heatmap plot. 57 | * Added argument 'add.key' to allow user to switch off the color legend. 58 | * Default 'color' changed from 'heat.colors(20)' to 'grey.colors(2)'. 59 | 60 | LDheatmap.marks() and LDheatmap.highlight(): 61 | * These functions now attempt detection of the viewport in which the target 62 | heat map was drawn and navigate to it automatically. 63 | 64 | Data sets: 65 | * Added example data-set: "CHBJPTData" containing "CHBJPTSNP" and "CHBJPTDist". 66 | * Changed supplied data files names from 'LDheatmapData', 'HapMap.dat' and 67 | 'distance' to 'CEUData', 'CEUSNP' and 'CEUDist' respectively. 68 | 69 | Other: 70 | * Removed 'myRainbow.colors()' 71 | * Added internal functions preDrawDetails.ldheatmap, postDrawDetails.ldheatmap, 72 | preDrawDetails.symbols and postDrawDetails.symbols to enable resizing of 73 | text when user resizes the window after drawing the heatmap. 74 | * Simplified example of drawing two heat maps on same graphic device. 75 | 76 | 0.2-1 77 | 78 | * Fixed bug of defaulting to black grid lines in new R version 2.3.0 79 | 80 | 0.2 81 | 82 | Re-write of the function to make use of grid graphics. 83 | Grid graphics allows users to modify the heatmap and extend the function in 84 | ways that are not possible with traditional R graphics. For examples of how 85 | to modify the plot using tools from the grid package, see the examples in 86 | the LDheatmap help file. 87 | 88 | Changes to function arguments: 89 | 1. The function now allows gdat to be one of the following: 90 | - a data frame of genotypes 91 | - an object of class LDheatmap 92 | - a matrix of pairwise LD measurements. 93 | The purpose of allowing gdat to be an object of class LDheatmap is to 94 | enable recycling of the LD measures calculations, that can be time consuming for large data files, from previous calls. 95 | If gdat is of class LDheatmap, the function recycles pairwise LD 96 | measurements from the original call and ignores the argument LDmeasure specified by the user in the second call. 97 | 98 | 2. Arguments x.image.show, y.image.show no longer used. 99 | to control the size of the image, use the viewport command from the grid package. 100 | See the LDheatmap help file for examples. 101 | 102 | 3. Changes to argument names: LDmeas is now LDmeasure, line.position is now 103 | geneMapLocation, x.length.position is now geneMapLabelX and 104 | y.length.position is now geneMapLabelY. 105 | 106 | 4. New argument newpage controls whether the heatmap is to be drawn on a 107 | new page. Default is to draw on a new page. 108 | 109 | 5. New argument name specifies the name of the top-level grid graphical object (grob) created by a call to the function LDheatmap. 110 | See the examples for usage in the LDheatmap help file. 111 | 112 | Changes to function output: 113 | A list of class 'LDheatmap' is produced. The list consists of the following items: 114 | LDmatrix - A matrix of linkage disequilibrium measurements. 115 | LDheatmapGrob - A graphical object. This object is first drawn and than 116 | returned by the LDheatmap function. 117 | heatmapVP - The Viewport in which the LDheatmap plot is drawn. 118 | genetic.distances - Vector of physical or genetic map distances. 119 | 120 | The LDheatmap plot output has been converted to grid graphics and is 121 | comprised of the following editable grid objects (grobs): 122 | "heatMap" - the color image of the heat map with its main title 123 | "geneMap" - the genetic map drawn on a diagonal line against the heatmap 124 | "Key" - the color key legend 125 | For further information on how to customise these objects, see 126 | the package demo and the examples in the LDheatmap help file. 127 | 128 | New functions: 129 | 1. LDheatmap.highlight - Highlight a genetic region in the LD heatmap. 130 | 2. LDheatmap.marks - Plot a symbol in the centers of cells 131 | representing the pairwise linkage disequilibria of specified pairs 132 | of SNPs. 133 | 134 | 135 | 0.1-5 136 | 137 | * Changed title in DESCRIPTION file 138 | 139 | 0.1-3 140 | 141 | * Enable user to select his own color scheme or blueToRed color scheme 142 | 143 | 0.1-2 144 | 145 | * Fixed bug in number calculated for legend "Genetic Map Length:" 146 | 147 | 0.1-1 148 | 149 | * Changed DESCRIPTION file 150 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | # ldheatmap - Plots measures of pairwise linkage disequilibria for SNPs 2 | # Copyright (C) 2004 J.Shin, S. Blay, N. Lewin-Koh, J.Graham, B.McNeney 3 | 4 | # To cite LDheatmap in publications use: 5 | # Shin J-H, Blay S, McNeney B and Graham J (2006). LDheatmap: An R 6 | # Function for Graphical Display of Pairwise Linkage Disequilibria 7 | # Between Single Nucleotide Polymorphisms. J Stat Soft, 16 Code Snippet 3 8 | 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | ########################################################################### 24 | 25 | #__________Construct a viewport for additional graphs and gene tracks__________________## 26 | constructVP <- function(LDheatmapGrob, location=0, flip) { 27 | 28 | x0 <- convertX(getGrob(LDheatmapGrob, "diagonal")[[1]][1], "npc", valueOnly=TRUE) 29 | x1 <- convertX(getGrob(LDheatmapGrob, "diagonal")[[1]][2], "npc", valueOnly=TRUE) 30 | y0 <- convertX(getGrob(LDheatmapGrob, "diagonal")[[2]][1], "npc", valueOnly=TRUE) 31 | y1 <- convertX(getGrob(LDheatmapGrob, "diagonal")[[2]][2], "npc", valueOnly=TRUE) 32 | map_len = sqrt((x1-x0)^2 + (y1-y0)^2) # genetic map length in npc units 33 | 34 | g_height <- g_x0 <- g_y0 <- 0 35 | if(!is.null(getGrob(LDheatmapGrob, "transcripts"))) { # if gene track has been plotted 36 | transcriptsVP <- getGrob(LDheatmapGrob, "transcripts")$vp 37 | if (flip) transcriptsVP <- transcriptsVP[[2]] 38 | g_x0 <- convertX(transcriptsVP$x, "npc", valueOnly=TRUE) 39 | g_y0 <- convertX(transcriptsVP$y, "npc", valueOnly=TRUE) 40 | g_height <- convertX(transcriptsVP$height, "npc", valueOnly=TRUE) 41 | } 42 | 43 | r_height <- r_x0 <- r_y0 <- 0 44 | if(!is.null(getGrob(LDheatmapGrob, "recombRate"))) { # if recombRate track has been plotted 45 | recombRateVP <- getGrob(LDheatmapGrob, "recombRate")$vp 46 | if (flip) recombRateVP <- recombRateVP[[2]] 47 | r_x0 <- convertX(recombRateVP$x, "npc", valueOnly=TRUE) 48 | r_y0 <- convertX(recombRateVP$y, "npc", valueOnly=TRUE) 49 | r_height <- convertX(recombRateVP$height, "npc", valueOnly=TRUE) 50 | } 51 | 52 | m_height <- m_x0 <- m_y0 <- 0 53 | if(!is.null(getGrob(LDheatmapGrob, "association"))) { # if association scatterplot has been plotted 54 | assocVP <- getGrob(LDheatmapGrob, "association")$vp 55 | if (flip) assocVP <- assocVP[[2]] 56 | m_x0 <- convertX(assocVP$x, "npc", valueOnly=TRUE) 57 | m_y0 <- convertX(assocVP$y, "npc", valueOnly=TRUE) 58 | m_height <- convertX(assocVP$height, "npc", valueOnly=TRUE) 59 | } 60 | 61 | # Set the viewport 62 | if (!flip) { # flip = FALSE 63 | angle <- 45 64 | genome_vp_just <- c("left", "top") 65 | } 66 | else { # flip = TRUE 67 | angle <- 45 68 | genome_vp_just <- c("left", "bottom") 69 | } 70 | vp <- viewport(angle=angle, just=genome_vp_just, width=map_len, 71 | x=min(x0, g_x0 - g_height*0.8, r_x0 - r_height*0.8, m_x0 - m_height*0.8) - location, 72 | y=max(y0, g_y0 + g_height*0.8, r_y0 + r_height*0.8, m_y0 + m_height*0.8) + location) 73 | return (vp) 74 | } 75 | 76 | #_______________________Move titles if covered up by additional plots____________________## 77 | moveTitles <- function(LDheatmapGrob, vp) { 78 | 79 | genemap_title_y <- convertX(getGrob(LDheatmapGrob,"geneMap::title")$y, 80 | "npc", valueOnly=TRUE) 81 | genemap_title_x <- convertX(getGrob(LDheatmapGrob,"geneMap::title")$x, 82 | "npc", valueOnly=TRUE) 83 | flipVP <- getGrob(LDheatmapGrob,"geneMap::diagonal")$vp 84 | 85 | if (is.null(flipVP)) { # flip = FALSE 86 | if (genemap_title_y == 0.3 & genemap_title_x == 0.5) # user used default setting 87 | LDheatmapGrob <- editGrob(LDheatmapGrob,"geneMap::title", y=unit(0.1, "npc"), 88 | x=unit(1.1, "npc"), just="right") 89 | grid.newpage() 90 | grid.draw(LDheatmapGrob) 91 | return(LDheatmapGrob) 92 | } 93 | 94 | # Get top of viewport coordinates in inches on the device 95 | pushViewport(LDheatmapGrob$vp) 96 | pushViewport(flipVP) 97 | vp_trans <- current.transform() 98 | temp <- c( 99 | convertX(vp$x, "inches", valueOnly=TRUE) - convertX(vp$height, "inches",valueOnly=TRUE)/sqrt(2), 100 | convertX(vp$y, "inches", valueOnly=TRUE) + convertX(vp$height, "inches", valueOnly=TRUE)/sqrt(2), 1) 101 | upViewport() 102 | tr <- temp %*% vp_trans # (x, y, 1) on device 103 | 104 | # Get genemap title coordinates in inches on the device 105 | vp_trans1 <- current.transform() 106 | genemap_title_y_inch <- convertY(getGrob(LDheatmapGrob,"geneMap::title")$y, "inches", valueOnly=TRUE) 107 | temp1 <- c(0, genemap_title_y_inch, 1) 108 | tr1 <- temp1 %*% vp_trans1 109 | 110 | 111 | # Move gene map title # if necessary 112 | new_genemap_title_y_inch <- t(solve(t(vp_trans1), t(tr)))[1,2] 113 | new_genemap_title_y_npc <- convertY(unit(new_genemap_title_y_inch, "inches"), "npc", valueOnly=TRUE) + 0.05 114 | 115 | LDheatmapGrob <- editGrob(LDheatmapGrob, "geneMap::title", 116 | y = unit(new_genemap_title_y_npc, "npc"), just=c("left","bottom")) 117 | 118 | 119 | # Move heat map title if necessary 120 | heatmap_title_y <- convertY(getGrob(LDheatmapGrob,"heatMap::title")$y, "npc", valueOnly=TRUE) 121 | genemap_title_height <- convertHeight(grobHeight(getGrob(LDheatmapGrob,"geneMap::title")), 122 | "npc", valueOnly=TRUE) 123 | 124 | if (heatmap_title_y < new_genemap_title_y_npc + genemap_title_height*3) { 125 | new_heatmap_title_y <- new_genemap_title_y_npc + genemap_title_height*3 126 | LDheatmapGrob <- editGrob(LDheatmapGrob, "heatMap::title", 127 | y = unit(new_heatmap_title_y, "npc")) 128 | } 129 | 130 | drawLDheatmapGrob(LDheatmapGrob) 131 | return(LDheatmapGrob) 132 | } 133 | 134 | drawLDheatmapGrob <- function(LDheatmapGrob) { 135 | heatmap_title_y <- convertY(getGrob(LDheatmapGrob,"heatMap::title")$y, "npc", valueOnly=TRUE) 136 | vp = viewport(height=1/heatmap_title_y, width=1, y=0.05, just="bottom", 137 | gp=gpar(cex=1/heatmap_title_y), name="container") 138 | grid.newpage() 139 | pushViewport(vp) 140 | grid.draw(LDheatmapGrob) 141 | popViewport() 142 | } 143 | 144 | 145 | -------------------------------------------------------------------------------- /docs/authors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Citation and Authors • LDheatmap 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 47 | 48 | 49 | 50 | 51 | 52 |
    53 |
    54 | 118 | 119 | 120 |
    121 | 122 |
    123 |
    124 | 127 | 128 |

    Shin J, Blay S, McNeney B and Graham J (2006). 129 | “LDheatmap: An R Function for Graphical Display of Pairwise 130 | Linkage Disequilibria Between Single Nucleotide 131 | Polymorphisms.” 132 | J Stat Soft, 16, pp. Code Snippet 3. 133 | http://stat.sfu.ca/statgen/research/ldheatmap.html. 134 |

    135 |
    @Article{,
    136 |   title = {LDheatmap: An R Function for Graphical Display of Pairwise 
    137 |                   Linkage Disequilibria Between Single Nucleotide 
    138 |                   Polymorphisms.},
    139 |   author = {J.-H. Shin and S. Blay and B. McNeney and J. Graham},
    140 |   journal = {J Stat Soft},
    141 |   volume = {16},
    142 |   year = {2006},
    143 |   pages = {{Code Snippet 3}},
    144 |   url = {http://stat.sfu.ca/statgen/research/ldheatmap.html},
    145 | }
    146 | 149 | 150 |
      151 |
    • 152 |

      Ji-Hyung Shin. Author. 153 |

      154 |
    • 155 |
    • 156 |

      Sigal Blay. Author. 157 |

      158 |
    • 159 |
    • 160 |

      Nicholas Lewin-Koh. Contributor. 161 |

      162 |
    • 163 |
    • 164 |

      Brad McNeney. Author, maintainer. 165 |

      166 |
    • 167 |
    • 168 |

      Gloria Yang. Contributor. 169 |

      170 |
    • 171 |
    • 172 |

      Matthew Reyers. Contributor. 173 |

      174 |
    • 175 |
    • 176 |

      Jinko Graham. Author. 177 |

      178 |
    • 179 |
    180 | 181 |
    182 | 183 |
    184 | 185 | 186 |
    187 | 190 | 191 |
    192 |

    Site built with pkgdown.

    193 |
    194 | 195 |
    196 |
    197 | 198 | 199 | 200 | 201 | 202 | 203 | -------------------------------------------------------------------------------- /R/recombRate.R: -------------------------------------------------------------------------------- 1 | #' @name recombRate 2 | #' @aliases recombRate 3 | #' @title Produce recombination rate plot. 4 | #' @description Plot average rates of recombination from the deCODE genetic map for a specified genetic sequence. 5 | #' @usage recombRate(minRange, maxRange, chromosome, genome = "hg19", vp = viewport(x = 0, 6 | #'y = 0.99, height = 0.04, just = c("left", "top")), view = "dense") 7 | #' @param minRange The sequence minimum range in base pairs. 8 | #' @param maxRange The sequence maximum range in base pairs. 9 | #' @param chromosome A character string identifying the chromosome. 10 | #' @param genome The genome assembly to use. The default is hg19, the most recent human genome assembly on 11 | #'the UCSC genome browser. 12 | #' @param vp A \code{viewport}. 13 | #' @param view Display mode. Possible values are \code{"dense"} (the default), \code{"squish"}, 14 | #'\code{"pack"} and \code{"full"}. 15 | #' @return A \code{grob} representing recombination rates. 16 | #' @references \url{http://genome.ucsc.edu/cgi-bin/hgTrackUi?g=recombRate} 17 | #' @author Sigal Blay and more 18 | #' @examples \donttest{ 19 | #'grid::grid.newpage() 20 | #'recombRate(129000000, 140000000, "chr7", "hg18") 21 | #'grid::grid.newpage() 22 | #'grid::pushViewport(grid::viewport(width=0.8, x=0.2, just="left")) 23 | #'recombRate(129000000, 140000000, "chr7", "hg18", view="full") 24 | #'grid::popViewport() 25 | #'} 26 | #' @keywords hplot 27 | #' @export 28 | 29 | # ldheatmap - Plots measures of pairwise linkage disequilibria for SNPs 30 | # Copyright (C) 2004 J.Shin, S. Blay, N. Lewin-Koh, J.Graham, B.McNeney 31 | 32 | # To cite LDheatmap in publications use: 33 | # Shin J-H, Blay S, McNeney B and Graham J (2006). LDheatmap: An R 34 | # Function for Graphical Display of Pairwise Linkage Disequilibria 35 | # Between Single Nucleotide Polymorphisms. J Stat Soft, 16 Code Snippet 3 36 | 37 | # This program is free software; you can redistribute it and/or modify 38 | # it under the terms of the GNU General Public License as published by 39 | # the Free Software Foundation; either version 2 of the License, or 40 | # (at your option) any later version. 41 | 42 | # This program is distributed in the hope that it will be useful, 43 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 44 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 45 | # GNU General Public License for more details. 46 | 47 | # You should have received a copy of the GNU General Public License 48 | # along with this program; if not, write to the Free Software 49 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 50 | 51 | ########################################################################### 52 | 53 | 54 | 55 | #________________Plot recomb Rate track from UCSC genome Browser_______________## 56 | recombRate <- function(minRange, maxRange, chromosome, genome="hg19", vp=viewport(x=0, y=0.99, height=0.04, just=c("left", "top")), view="dense") { 57 | requireNamespace("grid") 58 | map_len <- convertX(vp$width, "npc", valueOnly=TRUE) 59 | Range <- maxRange - minRange 60 | vp$xscale <- c(minRange, maxRange) 61 | vp$name <- "recombRate" 62 | 63 | session <- rtracklayer::browserSession() 64 | GenomeInfoDb::genome(session) <- genome 65 | query<-rtracklayer::ucscTableQuery(session, "recombRate", rtracklayer::GRangesForUCSCGenome(genome, chromosome,IRanges::IRanges(minRange, maxRange))) 66 | t<-rtracklayer::getTable(query) 67 | if (!dim(t)[1]) { # we got an empty table 68 | print ("The genetic region of the data does not correspond to any recombination rate data in the UCSC genome browser") 69 | return() 70 | } 71 | 72 | recombRate_title <- textGrob("Recombination Rate from deCODE", 73 | gp=gpar(fontsize=7, fontfamily="mono"), y=1, just=c("centre", "center"), 74 | name="recombRate_title", default.units="native") 75 | 76 | vp_height <- convertX(vp$height, "npc", valueOnly=TRUE) 77 | rect_height <- 0.5 78 | if (view == "squish") { 79 | rect_height <- 0.25 80 | vp$height <- unit(vp_height*2/3, "npc") 81 | } 82 | if (view == "full") { 83 | rect_height <- 1 84 | vp$yscale <- c(1+dim(t)[1] ,0) 85 | recombRate_title <- editGrob(recombRate_title, y=unit(0, "native")) 86 | vp$height <- unit((1+dim(t)[1])*vp_height/2, "npc") 87 | } 88 | if (view == "pack") { 89 | # Determine the plot line number for each row in t and save it in column t$plot_line 90 | t$plot_line <- 0 91 | t$plot_line[1] <- 1 92 | plot_lines_no <- 1 93 | if (dim(t)[1] > 1) { # more than a single gene in table 94 | text_width <- Range / map_len * convertWidth(grobWidth( 95 | textGrob(" 8.8 cM/Mb (Avg) ", gp=gpar(fontsize=7, fontfamily="mono"), vp=vp)), "npc", valueOnly=TRUE) 96 | for (i in 2:dim(t)[1]) { # for every gene in table starting with the second one 97 | for (j in 1:plot_lines_no) { 98 | # compare beggining of region minus text_width to highest end of gene in line j 99 | if (max(t[1:(i-1),][t[,"plot_line"]==j,"chromEnd"], na.rm = TRUE) 100 | < t[i,"chromStart"] - text_width) { 101 | t[i, "plot_line"] <- j 102 | break 103 | } 104 | } 105 | if (!t[i, "plot_line"]) 106 | t[i, "plot_line"] <- plot_lines_no <- plot_lines_no + 1 107 | } 108 | } 109 | rect_height <- 1 110 | vp$yscale <- c(2+plot_lines_no ,0) 111 | vp$height <- unit((2+plot_lines_no)*vp_height/2, "npc") 112 | } 113 | 114 | recombRate <- gTree(children=gList(recombRate_title), name="recombRate", vp=vp) 115 | 116 | 117 | # Read recomb rate for every every row in table t 118 | for (i in 1:dim(t)[1]) { 119 | 120 | if (view == "dense") y <- 0 121 | else if (view == "squish") y <- rect_height * (i%%2) 122 | else if (view == "full") y <- rect_height * i 123 | else y <- rect_height * (1+ t[i, "plot_line"]) 124 | 125 | value <- as.integer(t[i,"decodeAvg"]*200) 126 | color <- as.character(cut(value, breaks=c(0,seq(length=9, from=320, to=600), 10000), 127 | labels=grey.colors(10)[10:1])) 128 | rect <- rectGrob(x=max(minRange, t[i, "chromStart"]), default.units="native", 129 | width=min(maxRange, t[i, "chromEnd"]) - max(minRange, t[i, "chromStart"]), 130 | y=y, height=rect_height, just=c("left", "bottom"), gp=gpar(col="transparent", fill=color), 131 | name=paste("rect",i, sep="")) 132 | recombRate <- addGrob(recombRate , rect) 133 | if (view == "full" || view == "pack") { 134 | x <- 1; if (view == "pack") { x <- i } 135 | rectText <- textGrob(x=max(minRange, t[x, "chromStart"]), y=y, 136 | paste(round(t[i,"decodeAvg"],1)," cM/Mb (Avg) ",sep=""), just=c("right","top"), 137 | gp=gpar(fontsize=7, fontfamily="mono"), default.units="native", 138 | name=paste("text",i, sep="")) 139 | recombRate <- addGrob(recombRate , rectText) 140 | } 141 | } 142 | grid.draw(recombRate) 143 | return(recombRate) 144 | } 145 | 146 | -------------------------------------------------------------------------------- /R/LDheatmapHelpers.R: -------------------------------------------------------------------------------- 1 | # Functions below are used in conjunction with LDHeatmap.R 2 | # Provide supporting functionality for major function 3 | 4 | makeImageRect <- function(nrow, ncol, cols, name, byrow=TRUE) { 5 | xx <- (1:ncol)/ncol 6 | yy <- (1:nrow)/nrow 7 | # Creates coordinate pairs, repeating either column numbers (if byrow = TRUE) or row numbers (if byrow = FALSE) to force that type of fill 8 | if(byrow) { 9 | right <- rep(xx, nrow) 10 | top <- rep(yy, each=ncol) 11 | } else { 12 | right <- rep(xx, each=nrow) 13 | top <- rep(yy, ncol) 14 | } 15 | rectGrob(x=right, y=top, 16 | width=1/ncol, height=1/nrow, 17 | just=c("right", "top"), 18 | gp=gpar(col=NA, fill=cols), 19 | name=name) 20 | } 21 | 22 | makeImageText <- function(nrow, ncol, cols, name, flip = FALSE) { 23 | cols <- as.character(cols) 24 | cols[is.na(cols)] <- "" 25 | cols <- paste(" ", cols) 26 | xx <- (1:ncol)/ncol 27 | yy <- (1:nrow)/nrow 28 | 29 | # Need to fill cells in different order, as was done to generate image 30 | if(flip){ 31 | right <- rep(xx, each = nrow) 32 | top <- rep(yy, ncol) 33 | } 34 | else{ 35 | right <- rep(xx, nrow) 36 | top <- rep(yy, each=ncol) 37 | } 38 | textGrob(cols, x=right, y=top, 39 | gp=gpar(cex=0.3), 40 | just=c("right", "top"), 41 | name=name) 42 | } 43 | 44 | LDheatmapLegend.add <- function(color, LDmeasure, vp){ 45 | ImageRect<- makeImageRect(2,length(color), cols=c(rep(NA,length(color)),color[length(color):1]), 46 | "colorKey") 47 | keyVP <- viewport(x=1.1, y=-.10, height=.10, width=.5, just=c("right","bottom"), name="keyVP") 48 | #Adding the label 'Color key' 49 | if(LDmeasure=="r") { 50 | ttt<-expression(paste(R^2," Color Key")) 51 | } else { 52 | ttt<-"D' Color Key" 53 | } 54 | title<-textGrob(ttt, x=0.5, y=1.25, name="title", gp=gpar(cex=0.8)) 55 | 56 | #Adding labels to the color key 57 | labels<-textGrob(paste(0.2*0:5), x=0.2*0:5,y=0.25, gp=gpar(cex=0.6), name="labels") 58 | 59 | #Drawing ticks at the bottom axis of the color key 60 | ticks<-segmentsGrob(x0=c(0:5)*0.2 , y0=rep(0.4,6), x1=c(0:5)*0.2 , y1=rep(0.5,6),name="ticks") 61 | 62 | #Drawing a box around the color key 63 | box <- linesGrob(x=c(0,0,1,1,0), y=c(0.5,1,1,0.5,0.5), name="box") 64 | 65 | key <- gTree(children=gList(ImageRect, title, labels, ticks, box), name = "Key", vp=keyVP) 66 | key 67 | } 68 | 69 | LDheatmapMapNew.add <- function(nsnps, add.map, genetic.distances, 70 | geneMapLocation=0.15, 71 | geneMapLabelX=NULL, geneMapLabelY=NULL, 72 | distances="physical", vp=NULL, 73 | SNP.name=NULL, ind=0, flip=FALSE){ 74 | snp <- ((1:nsnps-1) + 0.5) / nsnps 75 | ##################### 76 | if(add.map){ 77 | min.dist <- min(genetic.distances) 78 | max.dist <- max(genetic.distances) 79 | total.dist <- max.dist - min.dist 80 | 81 | if(flip) geneMapLocation<- (-geneMapLocation) # geneMapLocation gets flipped, reflects the gene bar 82 | 83 | # Drawing the diagonal line 84 | seq.x <- c(0.5*geneMapLocation + 1/(nsnps*2), 85 | 1+0.5*geneMapLocation - 1/(nsnps*2)) 86 | seq.y <- c(-0.5*geneMapLocation + 1/(nsnps*2), 87 | 1-0.5*geneMapLocation - 1/(nsnps*2)) 88 | diagonal<-linesGrob(seq.x, seq.y, gp=gpar(lty=1), name="diagonal", vp=vp) # we draw the line with linesGrob, based on geneMapLocation seq 89 | 90 | ## Adding line segments to the plot: (point1 <-> point2) 91 | ## point1: relative position of a SNP on the scaled line 92 | ## point2: position of that SNP on the LD image 93 | regionx <- seq.x[1] + 94 | ((genetic.distances-min.dist)/total.dist)*(seq.x[2]-seq.x[1]) 95 | regiony <- seq.y[1] + 96 | ((genetic.distances-min.dist)/total.dist)*(seq.y[2]-seq.y[1]) 97 | segments <- segmentsGrob(snp, snp, regionx, regiony, name="segments", vp=vp) 98 | 99 | ## Adding the text indicating Physical length of the region under study 100 | if (distances=="physical") 101 | mapLabel <- paste("Physical Length:", round((total.dist/1000),1), 102 | "kb", sep="") 103 | else 104 | mapLabel <- paste("Genetic Map Length:", round(total.dist,1),"cM",sep="") 105 | 106 | if (!flip) { 107 | if(is.null(geneMapLabelY)) geneMapLabelY <- 0.3 108 | if(is.null(geneMapLabelX)) geneMapLabelX <- 0.5 109 | } 110 | else { 111 | if(is.null(geneMapLabelY)) geneMapLabelY <- 0.8 112 | if(is.null(geneMapLabelX)) geneMapLabelX <- 0.4 113 | } 114 | title <- textGrob(mapLabel, geneMapLabelX, geneMapLabelY, 115 | gp=gpar(cex=0.9), just="left", name="title") 116 | 117 | geneMap <- gTree(children=gList(diagonal, segments, title), name="geneMap") 118 | 119 | ## Labelling some SNPs 120 | if (!is.null(SNP.name) && (any(ind!=0))){ 121 | if (flip) { 122 | length_SNP_name <- max(nchar(SNP.name)) 123 | long_SNP_name <- paste(rep(8,length_SNP_name), collapse="") 124 | name_gap <- convertWidth(grobWidth(textGrob(long_SNP_name)), "npc",valueOnly=TRUE)/sqrt(2) 125 | diagonal<-linesGrob(seq.x, seq.y, gp=gpar(lty=1), name="diagonal", vp=vp) 126 | #diagonal<-linesGrob(seq.x+name_gap, seq.y-name_gap, gp=gpar(lty=1), name="diagonal", vp=vp) 127 | segments <- segmentsGrob(snp, snp, regionx, regiony, name="segments", vp=vp) 128 | #segments <- segmentsGrob(snp+name_gap, snp-name_gap, regionx+name_gap, regiony-name_gap, name="segments", vp=vp) 129 | 130 | ############################################ 131 | # Bug: symbols was set to NULL here for some reason 132 | symbols <- pointsGrob(snp[ind], snp[ind], pch="*", 133 | gp=gpar(cex=1.25, bg="blue", col="blue"), name="symbols", vp=vp) 134 | ############################################ 135 | # Figure out exact necessary coefficient for regionx and regiony with name_gap 136 | SNPnames <- textGrob(SNP.name, just="left", rot=-45, 137 | regionx[ind]-sqrt(2+0.5)*name_gap, regiony[ind]+sqrt(2+0.5)*name_gap, gp=gpar(cex=0.6, col="blue"), name="SNPnames", vp=vp) 138 | # Think of better reason to use the +0.5 139 | # snp[ind], snp[ind], gp=gpar(cex=0.6, col="blue"), name="SNPnames", vp=vp) 140 | title <- editGrob(title, y=unit(geneMapLabelY+name_gap, "npc")) 141 | } 142 | else{ 143 | symbols <- pointsGrob(snp[ind], snp[ind], pch="*", 144 | gp=gpar(cex=1.25, bg="blue", col="blue"), name="symbols", vp=vp) 145 | SNPnames <- textGrob(paste(" ", SNP.name), just="left", rot=-45, 146 | regionx[ind], regiony[ind], gp=gpar(cex=0.6, col="blue"), name="SNPnames", vp=vp) 147 | } 148 | geneMap <- gTree(children=gList(diagonal, segments, title, symbols, SNPnames),name="geneMap") 149 | }} # if(add.map) end 150 | 151 | else if (!add.map && !is.null(SNP.name) && (any(ind!=0))){ 152 | geneMap <- textGrob(paste(" ", SNP.name), just="left", rot=-45, 153 | snp[ind], snp[ind], gp=gpar(cex=0.6, col="blue"), 154 | name="SNPnames") 155 | if (flip) geneMap <- editGrob(geneMap, vp=vp) 156 | } 157 | else geneMap <- NULL 158 | 159 | geneMap 160 | } 161 | 162 | -------------------------------------------------------------------------------- /docs/reference/GIMAP5CEU.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Example data set for LDheatmap — GIMAP5.CEU • LDheatmap 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 45 | 46 | 47 | 48 | 49 | 50 |
    51 |
    52 | 86 | 87 | 88 |
    89 | 90 |
    91 |
    92 | 97 | 98 |
    99 | 100 |

    SNP genotypes on HapMap founders from the CEU population 101 | for SNPs spanning the GIMAP5 gene.

    102 | 103 |
    104 | 105 |
    data(GIMAP5.CEU)
    106 | 107 |

    Format

    108 | 109 |

    GIMAP5.CEU is a list with two elements: snp.data and snp.support. 110 | snp.data is a snp.matrix 111 | object containing the SNP genotypes. Rows correspond to 112 | subjects and columns correspond to SNPs. 113 | snp.support is a data frame with the following columns:

    114 | 115 | 116 | 117 | 118 |
    [,1]dbSNPallelescharacteralleles at each SNP
    [,2]Assignmentcharactersame as dbSNPalleles
    [,3]Chromosomecharacterchromosome (chr7 for all)
    [,4]Positionnumericphysical position
    119 | 120 |

    Details

    121 | 122 |

    SNP genotypes from HapMap release 27 123 | for SNPs in a 10KB region spanning 124 | the GIMAP5 gene. Data are on founders from the CEU population, 125 | described as Utah residents with Northern and Western European ancestry 126 | from the CEPH collection. 127 | Only those SNPs with minor allele frequency greater 128 | than 5% in all populations were retained. 129 | The base positions are from NCBI build 36 130 | (UCSC genome hg18).

    131 | 132 |

    Source

    133 | 134 |

    International HapMap Project www.hapmap.org

    135 | 136 |

    References

    137 | 138 |

    The International HapMap Consortium. A haplotype map of 139 | the human genome. Nature 437, 1299-1320. 2005.

    140 | 141 |

    See also

    142 | 143 | 144 | 145 | 146 |

    Examples

    147 |
    require(snpStats) # for the SnpMatrix data structure 148 | data(GIMAP5.CEU) 149 | LDheatmap(GIMAP5.CEU$snp.data,GIMAP5.CEU$snp.support$Position)
    150 |
    151 | 169 |
    170 | 171 |
    172 | 175 | 176 |
    177 |

    Site built with pkgdown.

    178 |
    179 | 180 |
    181 |
    182 | 183 | 184 | 185 | 186 | 187 | 188 | -------------------------------------------------------------------------------- /docs/reference/CEUData.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Example data set for LDheatmap — CEUData • LDheatmap 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 50 | 51 | 52 | 53 | 54 | 55 |
    56 |
    57 | 121 | 122 | 123 |
    124 | 125 |
    126 |
    127 | 132 | 133 |
    134 | 135 |

    CEUSNP: Genotypes on 15 SNPs for 60 people

    136 |

    CEUDist: Physical map positions of the 15 SNPs in CEUSNP

    137 | 138 |
    139 | 140 |
    data(CEUData)
    141 | 142 |

    Format

    143 | 144 |

    CEUSNP: A dataframe of SNP genotypes. 145 | Each row represents an individual. 146 | Each column represents a SNP.

    147 |

    CEUDist: A vector of integers, representing SNP physical map locations on the chromosome.

    148 | 149 |

    Source

    150 | 151 |

    International HapMap Project www.hapmap.org

    152 | 153 |

    Details

    154 | 155 |

    Data on SNPs with minor allele frequency greater 156 | than 5% from a 9kb region of chromosome 7 (base positions 126273659 157 | through 126282556 from release 7 of the International HapMap Project). 158 | Genotypes from 30 parent-offspring trios (both 159 | parents, one offspring) were obtained. 160 | The 30 trios are taken from the so-called CEPH families, a set of 161 | multi-generational families from Utah with ancestry from northern and 162 | western Europe. From this set of 90 people, 60 parents were extracted.

    163 | 164 |

    References

    165 | 166 |

    The International HapMap Consortium. A haplotype map of 167 | the human genome. Nature 437, 1299-1320. 2005.

    168 | 169 | 170 |

    Examples

    171 |
    data(CEUData)
    172 |
    173 | 189 |
    190 | 191 |
    192 | 195 | 196 |
    197 |

    Site built with pkgdown.

    198 |
    199 | 200 |
    201 |
    202 | 203 | 204 | 205 | 206 | 207 | 208 | -------------------------------------------------------------------------------- /docs/reference/LDheatmap.addGrob.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Add a graphical object to an LDheatmap plot — LDheatmap.addGrob • LDheatmap 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 50 | 51 | 52 | 53 | 54 | 55 |
    56 |
    57 | 121 | 122 | 123 |
    124 | 125 |
    126 |
    127 | 132 | 133 |
    134 | 135 |

    Add a graphical object to an LDheatmap plot such that the x-axis corresponds 136 | to the physical map on the heatmap.

    137 | 138 |
    139 | 140 |
    LDheatmap.addGrob(LDheatmap, grob, height = 0.2)
    141 | 142 |

    Arguments

    143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 |
    LDheatmap

    An object of class LDheatmap.

    grob

    A graphical object of classgrob.

    height

    The height of the viewport in which the grob will be placed.

    158 | 159 |

    Value

    160 | 161 |

    An object of class LDheatmap given as an argument, with the grob 162 | LDheatmapGrob modified to inclue the new child grob.

    163 | 164 |

    See also

    165 | 166 | 167 | 168 | 169 |

    Examples

    170 |
    # Add an empty rectangle frame 171 | data(GIMAP5.CEU) 172 | ll<-LDheatmap(GIMAP5.CEU$snp.data,GIMAP5.CEU$snp.support$Position,flip=TRUE)
    llplusgrob<-LDheatmap.addGrob(ll, grid::rectGrob())
    173 |
    174 | 191 |
    192 | 193 |
    194 | 197 | 198 |
    199 |

    Site built with pkgdown.

    200 |
    201 | 202 |
    203 |
    204 | 205 | 206 | 207 | 208 | 209 | 210 | -------------------------------------------------------------------------------- /docs/reference/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Function reference • LDheatmap 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 47 | 48 | 49 | 50 | 51 | 52 |
    53 |
    54 | 118 | 119 | 120 |
    121 | 122 |
    123 |
    124 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 142 | 143 | 144 | 145 | 148 | 149 | 150 | 151 | 154 | 155 | 156 | 157 | 160 | 161 | 162 | 163 | 166 | 167 | 168 | 169 | 172 | 173 | 174 | 175 | 178 | 179 | 180 | 181 | 184 | 185 | 186 | 187 | 190 | 191 | 192 | 193 | 196 | 197 | 198 | 199 | 202 | 203 | 204 | 205 | 208 | 209 | 210 | 211 | 214 | 215 | 216 | 217 | 220 | 221 | 222 | 223 |
    139 |

    All functions

    140 |

    141 |
    146 |

    CEUData

    147 |

    Example data set for LDheatmap

    152 |

    CHBJPTData

    153 |

    Example of data set for LDHeatmap

    158 |

    GIMAP5.CEU

    159 |

    Example data set for LDheatmap

    164 |

    GIMAP5

    165 |

    Example data set for LDHeatmap

    170 |

    LDheatmap()

    171 |

    This function produces a pairwise LD plot.

    176 |

    LDheatmap.addGenes()

    177 |

    Add gene plot to an LDheatmap object.

    182 |

    LDheatmap.addGrob()

    183 |

    Add a graphical object to an LDheatmap plot

    188 |

    LDheatmap.addRecombRate()

    189 |

    Add recombination rate plot to an LD heat map.

    194 |

    LDheatmap.addScatterplot()

    195 |

    Add a scatter plot to an LDheatmap object

    200 |

    LDheatmap.highlight()

    201 |

    Highlight a genetic region in the linkage disequilibrium heat map

    206 |

    LDheatmap.marks()

    207 |

    Plots a symbol in the centers of cells of the heat map image

    212 |

    plotGenes()

    213 |

    Plot genes from a specified region of the human genome.

    218 |

    recombRate()

    219 |

    Produce recombination rate plot.

    224 |
    225 | 226 | 232 |
    233 | 234 |
    235 | 238 | 239 |
    240 |

    Site built with pkgdown.

    241 |
    242 | 243 |
    244 |
    245 | 246 | 247 | 248 | 249 | 250 | 251 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Graphical Display of Pairwise Linkage Disequilibria Between SNPs • LDheatmap 9 | 10 | 11 | 12 | 13 | 20 | 21 | 22 | 26 | 27 | 28 |
    29 |
    93 | 94 | 95 | 96 |
    97 |
    98 | 99 | 100 | 101 | 102 |
    103 |

    104 | LDheatmap 105 |

    106 |

    LDheatmap() is used to produce a graphical display, as a heat map, of pairwise linkage disequilibrium (LD) measurements for SNPs. The heat map is a false color image in the upper-left diagonal of a square plot. A line parallel to the diagonal of the image indicating the physical or genetic map positions of the SNPs may be added, along with text reporting the total length of the genomic region considered. Users may also display the heatmap “flipped” below a horizontal line indicating the map positions of the SNPs. In this orientation, tracks may be added above the genetic map.

    107 |
    108 |
    109 |

    110 | Installation

    111 |
    # Install the latest release version from CRAN and the
    112 | # imported/suggested BioConductor packages with
    113 | install.packages("LDheatmap")
    114 | source("https://bioconductor.org/biocLite.R")
    115 | biocLite(c("snpStats","rtracklayer","GenomicRanges","GenomInfoDb","IRanges"))
    116 | 
    117 | # Install the latest development version from GitHub with
    118 | devtools::install_github("SFUStatgen/LDheatmap")
    119 |
    120 |
    121 |

    122 | Homepage

    123 |

    https://sfustatgen.github.io/LDheatmap/index.html

    124 |
    125 |
    126 | 127 | 161 | 162 |
    163 | 164 | 165 |
    168 | 169 |
    170 |

    Site built with pkgdown.

    171 |
    172 | 173 |
    174 |
    175 | 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /docs/reference/recombRate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Produce recombination rate plot. — recombRate • LDheatmap 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 49 | 50 | 51 | 52 | 53 | 54 |
    55 |
    56 | 120 | 121 | 122 |
    123 | 124 |
    125 |
    126 | 131 | 132 |
    133 | 134 |

    Plot average rates of recombination from the deCODE genetic map for a specified genetic sequence.

    135 | 136 |
    137 | 138 |
    recombRate(minRange, maxRange, chromosome, genome = "hg19", vp = viewport(x = 0,
    139 | y = 0.99, height = 0.04, just = c("left", "top")), view = "dense")
    140 | 141 |

    Arguments

    142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 169 | 170 |
    minRange

    The sequence minimum range in base pairs.

    maxRange

    The sequence maximum range in base pairs.

    chromosome

    A character string identifying the chromosome.

    genome

    The genome assembly to use. The default is hg19, the most recent human genome assembly on 159 | the UCSC genome browser.

    vp

    A viewport.

    view

    Display mode. Possible values are "dense" (the default), "squish", 168 | "pack" and "full".

    171 | 172 |

    Value

    173 | 174 |

    A grob representing recombination rates.

    175 | 176 |

    References

    177 | 178 |

    http://genome.ucsc.edu/cgi-bin/hgTrackUi?g=recombRate

    179 | 180 | 181 |

    Examples

    182 |
    # NOT RUN {
    183 | grid.newpage()
    184 | recombRate(129000000, 140000000, "chr7", "hg18")
    185 | grid.newpage()
    186 | pushViewport(viewport(width=0.8, x=0.2, just="left"))
    187 | recombRate(129000000, 140000000, "chr7", "hg18", view="full")
    188 | popViewport()
    189 | # }
    190 |
    191 | 208 |
    209 | 210 | 220 |
    221 | 222 | 223 | 224 | 225 | 226 | 227 | --------------------------------------------------------------------------------