tanghaibao / jcvi

Python library to facilitate genome assembly, annotation, and comparative genomics
BSD 2-Clause "Simplified" License
757 stars 186 forks source link

How to change the color and width of microsynteny visualization? #236

Closed yuanhelianyi closed 3 years ago

yuanhelianyi commented 4 years ago

Dear Mr. Tang,

Thanks for developing this useful package. I have two questions when I plot the microsynteny visualization. The synteny line is very weaker in my figure, which is probably caused by the wide range. I want to change a darker color and expand the width to get a better view. Can you teach me how to accomplish?

Sincerely,

Jing

tanghaibao commented 4 years ago

@yuanhelianyi

Please post a screenshot if possible. Please note that in practice, microsynteny plot cannot fit too many genes, a rule of thumb is < 100 genes. So try to just plot a smaller region.

Haibao

yuanhelianyi commented 4 years ago

Dear Haibao,

Thank you. I have tried to plot a smaller region, seen as the picture below. Although it becomes better, but lines in the picture are also weak. I guess it should be caused by low gene density in this big genome. Following your guide paper, I just reedit the "blocks" file like ploting a macrosynteny visualization which has a highlighted specific block. Finally, I get a black and thick line figure, which is a bit exaggerated. Where can I modify it to to change a d

屏幕快照 2020-04-24 下午2 13 36 屏幕快照 2020-04-24 下午2 17 19 屏幕快照 2020-04-24 下午2 30 20

arker color and increase the width to get a better view?

Sincerely,

Jing

awesomedeer commented 4 years ago

@yuanhelianyi First I think it's not a SMALLER region for microsynteny that you have so many genes to show. g*AT000001G AG000002G the "g" is the abbv for hilighting the green wedges. You can also try to change the color like: #333333*AT000001G AG000002G. At the end, I don't know how to set the thickness parameter.

Song

ohdongha commented 3 years ago

Dear Haibao and Song, @tanghaibao @awesomedeer Pardon me for hitchhiking on a thread, with (what I think) a remotely related question.

Is there a way to color all connectors between particular two contigs/scaffolds only, when there are more than two contigs/scaffolds shown in a microsynteny plot?

For example, I would like to have a darker gray color for ribbons connecting paralogs of Phragmites australis below, while ribbons between Setaria and Phragmites stay the same color: Copy ofblock Sit_s9 withParalogs I tried to add "#a0a0a0" at the beginning of a Phragmites geneID (in the block file), but it didn't work. Adding "#a0a0a0" at the beginning (i.e. in front of the Setaria geneID) of a line in the block file colored all connections among all genes from the three contigs/scaffold on the same line in the block file.

It would be great if ribbon colors between two contigs/scaffolds can be set in the layout file where we set the edges. Is there such a functionality?

Please help. Thanks! Dong-Ha

P.S. In case needed, attached are block and layout files: Sit_Pau_MCscan_example.zip

awesomedeer commented 3 years ago

Hi Dong-Ha As far as I know, this parameter may not exist which means you can not change ribbon colors between certain contigs. I would suggest rather you make a triangle layout and the ribbons will be easier to be selected in AI/PS software. Then you can change the colors. @tanghaibao may have better solution.

Song

tanghaibao commented 3 years ago

@ohdongha @awesomedeer

There is a workaround but requires modifying the blocks file. You mentioned that the ribbon color works on a per-line basis. That is correct. So we could do something like:

-r*A    B    C
+r*A    B    .
+g*.    B    C
+b*A    .    C

We basically replace a single line (hence a single color) and blow that up into three separate lines for each pairwise ribbon. That way you could use different colors for each pair. Notice that you'll need to place a "." for the empty column. So in the example above, instead of red (r) color across, B-C pair shows green (g) instead and A-C pair shows blue (g) instead.

Whatever we specify before * is the color, as usual, we could use either a color shorthand, a full color name, or hex.

I have not tried this in practice but I feel that this could just work.

Haibao

ohdongha commented 3 years ago

Thanks, @tanghaibao and @awesomedeer. The trick to decompose three-way lines worked!

The only thing is that in the contig/scaffold/gene locus drawing, the gene models came in front of the ribbons connecting ortholog and paralog pairs, but the thick rod indicating the contig/scaffold is behind the ribbons. But this is minor and perhaps addressable by moving Phragmites contigs around.

Copy ofblock Sit_s9 Pau_c11_c324

Regarding the z-depth of ribbons, it seems like ribbons including the first column gene loci are drawn first and ribbons connecting 2nd and 3rd columns are drawn on top of them (and changing the order of lines in the block file did not affect the z-depth).

Dong-Ha

@ohdongha @awesomedeer

There is a workaround but requires modifying the blocks file. You mentioned that the ribbon color works on a per-line basis. That is correct. So we could do something like:

-r*A    B    C
+r*A    B    .
+g*.    B    C
+b*A    .    C

We basically replace a single line (hence a single color) and blow that up into three separate lines for each pairwise ribbon. That way you could use different colors for each pair. Notice that you'll need to place a "." for the empty column. So in the example above, instead of red (r) color across, B-C pair shows green (g) instead and A-C pair shows blue (g) instead.

Whatever we specify before * is the color, as usual, we could use either a color shorthand, a full color name, or hex.

I have not tried this in practice but I feel that this could just work.

Haibao