Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Annotations on a Plot #15

Open
sahirbhatnagar opened this issue Sep 20, 2017 · 1 comment
Open

Multiple Annotations on a Plot #15

sahirbhatnagar opened this issue Sep 20, 2017 · 1 comment
Labels

Comments

@sahirbhatnagar
Copy link
Owner

From Jasmin Divers via email:
I have a quick question or you. Under section 3.2 of the vignette where you talk about annotations. The example you provided works well for a single SNP, but what if I wanted to annotate all the SNPs that reached a specific significant level. Passing a list of SNPs to your call to the magrittr package returns nothing – not even an error message. In my case, the xc and yc vectors contain 10 elements, instead of tfe x- and y-axis of the SNP with the smallest p-value.

@sahirbhatnagar
Copy link
Owner Author

Thanks for your interest in this packages.
Here is a working example of how to add multiple annotations, although the result is not aesthetically pleasing since there is alot of overlap between the top hits in the data provided by the package:

pacman::p_load(manhattanly)
pacman::p_load(magrittr)

p <- manhattanly(HapMap, snp = "SNP", gene = "GENE",
            annotation1 = "DISTANCE", annotation2 = "EFFECTSIZE",
            highlight = significantSNP)

# get the x and y coordinates from the pre-processed data
plotData <- manhattanr(HapMap, snp = "SNP", gene = "GENE")[["data"]]

# annotate the smallest 10 p-values
annotate <- plotData[order(plotData$P),][1:10,]

# x and y coordinates of SNPs with smallest p-values
xc <- annotate$pos
yc <- annotate$logp

p %>%
  add_annotations(x = xc,
                  y = yc,
                  text = paste0(annotate$SNP,"<br>","GENE: ",annotate$GENE),
                  xref = "x",
                  yref = "y",
                  showarrow = TRUE,
                  arrowhead = 4,
                  arrowsize = .5,
                  ax = 20,
                  ay = -40)

You can look at the multiple annotations help page for plotly to perhaps see if there is a way of moving them around if the above code doesn't suit your data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant