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

mmplot to support group based labelling #16

Closed
Kirk3gaard opened this issue Sep 21, 2018 · 3 comments
Closed

mmplot to support group based labelling #16

Kirk3gaard opened this issue Sep 21, 2018 · 3 comments

Comments

@Kirk3gaard
Copy link
Collaborator

To highlight a set of bins it could be useful to provide one label at the center for the contigs in the bin rather than a label for each contig. Much like it is possible in ampvis2 (https://github.com/MadsAlbertsen/ampvis2/blob/master/R/amp_ordinate.R) to provide a single "sample_colorframe_label".

@Kirk3gaard
Copy link
Collaborator Author

Kirk3gaard commented Oct 2, 2018

labelframe<-data %>% 
  select(starts_with("cov"),binID) %>%
  filter(!is.na(binID)) %>%
  group_by(binID) %>%
  replace(., is.na(.), 0) %>%
  summarise_all(funs(mean))

mmplot(...)+
geom_text_repel(
    data          = labelframe,
    aes(label=binID),
    nudge_x       = 1,
    segment.size  = 0.2,
    segment.color = "grey50",
    direction     = "y",
    hjust         = 1,
    size=5
  )

@KasperSkytte
Copy link
Owner

Something like this, where you just specify a column with groups?

library(mmgenome2)
#> Loading required package: ggplot2
mmsubset <- mmextract(mmgenome2, 
                      data.frame(cov_C13.11.25 = c(1.253, 1.298, 2.78, 3.006, 1.772),
                                 cov_C14.01.09 = c(46.774, 26.499, 15.013, 28.049, 48.58))
                      )
#> 185 scaffolds (or 2.39% of the scaffolds in mm, weighted by length) remain after 97100 of 97285 scaffolds have been filtered.
bin1 <- mmextract(mmsubset, 
                  data.frame(cov_C13.11.25 = c(1.239, 1.273, 1.732, 2.075, 1.658),
                             cov_C14.01.09 = c(30.96, 41.872, 45.587, 40.788, 31.734))
                  )
#> 54 scaffolds (or 53.19% of the scaffolds in mm, weighted by length) remain after 131 of 185 scaffolds have been filtered.
bin2 <- mmextract(mmsubset,
                  data.frame(cov_C13.11.25 = c(2.052, 2.479, 2.874, 2.527),
                             cov_C14.01.09 = c(20.203, 29.722, 25.62, 17.494))
                  )
#> 41 scaffolds (or 43.23% of the scaffolds in mm, weighted by length) remain after 144 of 185 scaffolds have been filtered.
mmsubset$bin <- NA
mmsubset$bin[which(mmsubset$scaffold %in% bin1$scaffold)] <- "bin1"
mmsubset$bin[which(mmsubset$scaffold %in% bin2$scaffold)] <- "bin2"

mmplot(mmsubset,
            x = "cov_C13.11.25",
            y = "cov_C14.01.09",
            label_bins = "bin")

Created on 2018-10-03 by the reprex package (v0.2.1)

@KasperSkytte
Copy link
Owner

Main addition is this

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

No branches or pull requests

2 participants