jtlovell / GENESPACE

Other
189 stars 27 forks source link

Cannot invert chromosomes in riparian plot #52

Closed dinahparker closed 1 year ago

dinahparker commented 1 year ago

Hello, first of all wanted to say thanks for the program, it works great and generates some beautiful plots! As for my issue, I got through all the steps and wanted to customize the plot, but I can't get the chromosome inversion to work properly.

plot_riparianHits( gpar, refGenome = "KVL1802", genomeIDs = c("KVL1802", "KVL1803", "KVL1801", "KVL1808", "KVL1807", "KVL1806"), invertTheseChrs = data.frame(genome = "KVL1803", chr = 3), returnSourceData = F, verbose = F)

Whether I run the plot with a specified inversion or not, I get the same plot.

plot_inverse.pdf plot.pdf

I also don't see an asterisk in chr 3 in KVL1803 in the "inverted" version, which makes me think it's simply not working for some reason. Did I make a syntax error somewhere?

Thanks in advance!

jtlovell commented 1 year ago

what version of GENESPACE are you using? If v0.9x, my guess is that there isn't a chromosome called "3" in KVL1803. plot_riparian automatically strips some strings off the chromosome names. To get the full chr name in the plot, use

plot_riparianHits( gpar, refGenome = "KVL1802", genomeIDs = c("KVL1802", "KVL1803", "KVL1801", "KVL1808", "KVL1807", "KVL1806"), invertTheseChrs = data.frame(genome = "KVL1803", chr = 3), returnSourceData = F, verbose = F, chrLabFun = function(x) x)
dinahparker commented 1 year ago

I am working with GENESPACe v0.9.4. I know that in my gff file, all of the chromosomes are referred to as chr_1, chr_2, etc. When I add ran your code, my plot now has these chromosome names instead as seen in the attached pdf.

plot_chr.pdf

But when I try to invert using the actual name of the chromosome, I get an error saying that chr_3 isn't found

> plot_riparianHits( gpar, refGenome = "KVL1802", genomeIDs = c("KVL1802", "KVL1803", "KVL1801", "KVL1808", "KVL1807", "KVL1806"), invertTheseChrs = data.frame(genome = "KVL1803", chr = chr_3), returnSourceData = F, verbose = F, chrLabFun = function(x) x)

Error in data.frame(genome = "KVL1803", chr = chr_3) : object 'chr_3' not found

I don't get this error if I just use "3" to refer to the chromosome. I'm attaching a copy of the parsed .gff file for KVL1803 just for reference, but let me know if there's anything else that would help.

KVL1803.gff.gz

jtlovell commented 1 year ago

yeah, R is tricky ... you don't need to quote numbers/integers. you do need to quote character strings, otherwise it assumes you are passing an object. so, you need plot_riparianHits( gpar, refGenome = "KVL1802", genomeIDs = c("KVL1802", "KVL1803", "KVL1801", "KVL1808", "KVL1807", "KVL1806"), invertTheseChrs = data.frame(genome = "KVL1803", chr = "chr_3"), returnSourceData = F, verbose = F, chrLabFun = function(x) x)

dinahparker commented 1 year ago

Oh I got it, easy fix apparently! Thanks a bunch for helping out :)

jtlovell commented 1 year ago

np. glad it worked. nice synteny map btw! also, for future reference, you can pass multiple genomes and chrs via:

plot_riparianHits( gpar, refGenome = "KVL1802", genomeIDs = c("KVL1802", "KVL1803", "KVL1801", "KVL1808", "KVL1807", "KVL1806"), invertTheseChrs = data.frame(genome = c("KVL1803", "KVL1802","KVL1802"), chr = c("chr_3", "chr_6", "chr_7")), returnSourceData = F, verbose = F)