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

highlighting regions of interest #27

Closed
pawanchk opened this issue Jul 29, 2023 · 2 comments
Closed

highlighting regions of interest #27

pawanchk opened this issue Jul 29, 2023 · 2 comments

Comments

@pawanchk
Copy link

Hi,

I obtained the copy number plot using plot_segments function, now I want to highlight certain regions of interest so I tried the geom_rect function but the highlight does not show up. Can I please know what is the best way to highlight certain regions of interest ?

This is what I have tried -
base_plot + geom_rect(genes, mapping=aes(xmin=geneStart, xmax=geneEnd, ymin=-Inf, ymax=Inf, fill=geneName)

where genes is a data frame containing regions of interest to be highlighted - it has 4 columns - chr, geneStart, geneEnd, geneName

Any advice would be very helpful.

Best Regards,
Pawan

@Militeee
Copy link
Contributor

Hi @pawanchk,
So I think the main problem is with the coordinates of the gene, when we plot we generally use absolute coordinates.
We have this function to convert from relative to absolute, that you can call with CNAqc:::relative_to_absolute_coordinates.
Anyway, it works on a CNAqc object but you can easily adapt it to your table. THa you use the transformed start and end in the geom:rect. Let me know if something else is wrong.

relative_to_absolute_coordinates = function(x, cna)
{
  reference_genome = CNAqc:::get_reference(x$reference_genome)

  vfrom = reference_genome$from
  names(vfrom) = reference_genome$chr

  cna %>%
    mutate(from = from + vfrom[chr],
           to = to + vfrom[chr])
}

@Militeee Militeee reopened this Sep 18, 2023
@caravagn
Copy link
Collaborator

I think this should be closed and re-opened if required.

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

3 participants