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

How to find which coordinates are repeating in target chromosomes #27

Open
khush876 opened this issue Jun 9, 2021 · 2 comments
Open

Comments

@khush876
Copy link

khush876 commented Jun 9, 2021

Hi,

It is very useful tool and the graphics are amazing. However, I have some issues if you can address

  1. How to add color to the synteny analysis as black and white is not appropriate
  2. Is there a way I can plot (plot_synteny) of all the chromosome as a one figure
  3. Plot_coverage gives very nice graphics, but I am intrested to know which segments of one chromosome is recombinant in other. I have 9 chromosome (target) and it seems that my query is showing lot of recombination. Is there a way to find out more detail (or circular plot) to map those synteny like BioCircos?
    Thank you
@dwinter
Copy link
Owner

dwinter commented Jul 20, 2021

Hi @khush876 ,

Sorry for the delay in responding to this. I have recently started a new position, so been a bit hectic finishing up one job and startng the next.

Some answers to you points,

(1) This is something we can add quite easily, for now you could use this function in place of plot_synteny

plot_synteny_colourfullly <- function (ali, q_chrom, t_chrom, centre = TRUE, rc = FALSE, xlab = "Position in query", 
    ylab = "", x_labeller = Mb_lab, ribbon_colour="grey80", seq_colour="white") 
{
    synt_df <- pafr:::synteny_data(ali, q_chrom = q_chrom, t_chrom = t_chrom, 
        rc = rc)
    cs <- pafr::chrom_sizes(ali)
    tlen <- cs$tlens$tlen[cs$tlens$tname == t_chrom]
    qlen <- cs$qlens$qlen[cs$qlens$qname == q_chrom]
    seq_lens <- data.frame(seq = factor(c(q_chrom, t_chrom)), 
        start = 0, end = c(qlen, tlen))
    if (centre) {
        os <- abs(tlen - qlen)/2
        if (qlen > tlen) {
            synt_df[["x"]][synt_df[["seq"]] == t_chrom] <- synt_df[["x"]][synt_df[["seq"]] == 
                t_chrom] + os
            seq_lens[2, 2:3] <- seq_lens[2, 2:3] + os
        }
        else {
            synt_df[["x"]][synt_df[["seq"]] == q_chrom] <- synt_df[["x"]][synt_df[["seq"]] == 
                q_chrom] + os
            seq_lens[1, 2:3] <- seq_lens[1, 2:3] + os
        }
    }
    if (q_chrom > t_chrom) {
        bottoms <- c(2.05, 0.8)
        tops <- c(2.2, 0.95)
    }
    else {
        bottoms <- c(0.8, 2.05)
        tops <- c(0.95, 2.2)
    }
    ggplot() + geom_polygon(data = synt_df, aes_string(x = "x", 
        y = "seq", group = "block_id"), fill = ribbon_colour, colour = "black") + 
        geom_rect(data = seq_lens, aes_string(xmin = "start", 
            xmax = "end", ymin = "bottoms", ymax = "tops"), colour = "black", 
            fill = seq_colour) + scale_x_continuous(xlab, labels = x_labeller) + 
        ylab(ylab)
}

Using the example from the README you could do

#beautiful....
plot_synteny_colourfullly(long_ali, q_chrom="Q_chr3", t_chrom="T_chr4", centre=TRUE, seq_colour = "forestgreen", ribbon_colour = "pink")

(2) In short no. I think doing this well would be quite difficult (how to order target and query sequences, etc) so it's not something that is likely to be on the horizon. I have produce nice figures for thiese sorts of plots with MCScan (https://github.com/tanghaibao/mcscan) and if we get #26 of the ground we might be able to make whole genome circos plots with similar effects

(3)I'm not sure exactly what you are after, with #26 we hope to make it quick and easy to produce circos plots. It is also possible to extract the location of a given aligned-block from the .paf table, and the next release will allow you to extract bed format corrdinates from an alignment. If you have a specific you don't mind sharing you can send it to me at [email protected] and I can try to make some time to look at it?

@khush876
Copy link
Author

Hi David,

Thank you so much for sending the code. It is really great. It gives really beautiful synteny plot. I am very happy that I can make different color for each chromosome.

  1. In this question, I was talking about plotting, all q_chrom and t_chrom from .paf file into one plot

plot 1 <- q_chrom="Q_chr1", t_chrom="T_chr1"
plot 2 <- q_chrom="Q_chr2", t_chrom="T_chr2"
plot 3 <- q_chrom="Q_chr3", t_chrom="T_chr3"

superplot <- plot 1, plot 2, plot 3

  1. I will send you my plots on your email.

Thank you

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