Colour links in accordance to starting chromosome + how to plot very close labels

545 views
Skip to first unread message

Chiara C

unread,
Jul 3, 2014, 3:48:26 AM7/3/14
to circos-data-...@googlegroups.com
Hello,

I am trying to colour links in accordance to their starting chromosome in a mono-karyotipe circos plot. I tried to follow the procedure described in the Course section of the site, but it doesn't work, I think because in that case the links are between mouse and human chromosomes, so the code/variable names have to be adjusted somehow.

Moreover, I am also trying to plot very close labels, which disappear due to overlapping texts.

I tried defining two different group of labels with two different link dimensions, but still some labels don't get plotted. I tried to play around in different ways with the snuggling parameter, but it did not work. Does anyone have any suggestions?

Thank you very much


Chiara


Code attached:


<<include etc/colors_fonts_patterns.conf>>

<<include ideogram.conf>>
#<<include ticks.conf>>


<image>
<<include etc/image.conf>>
#radius* = 2100p
</image>

chromosomes_units           = 1000000
chromosomes_display_default = yes

# specify the karyotype file here - try other karyotypes in data/karyotype
karyotype = data/karyotype/karyotype.mouse.mm10.txt


<links>

z             = 0
radius        = 0.975r
bezier_radius = 0.2r

<link>
bezier_radius = undef
show          = yes
color           = black_a5
thickness     = 4
file          = LINEAR_trans_no_covariates_circos.txt
record_limit  = 5000

<rule>
condition      =  1

# WRONG ROW:
color          =  eval(sprintf("chr%s",substr(var(from(CHR)),2)))

</rule>

</link>



</links>




<plots>
type       = text
color      = black
label_font = default
#label_size = 30p

<plot>
file = LINEAR_trans_no_covariates_etichette2_circos.txt
r1   = 1r+200p
r0   = 1r
label_size = 35p
show_links     = yes
link_dims      = 0p,0p,270p,0p,10p
link_thickness = 3p
link_color     = red
ticks_separation = 0.2p
</plot>


<plot>
file = LINEAR_trans_no_covariates_etichette_circos.txt
r1   = 1r+200p
r0   = 1r
label_size = 35p
show_links     = yes
link_dims      = 0p,0p,70p,0p,10p
link_thickness = 3p
link_color     = red
ticks_separation = 0.2p
</plot>



</plots>


<<include etc/housekeeping.conf>>

Martin Krzywinski

unread,
Jul 3, 2014, 7:35:31 PM7/3/14
to circos-data-...@googlegroups.com
> color =  eval(sprintf("chr%s",substr(var(from(CHR)),2)))

Yes, this isn't right. The from() function is used in the condition, to test whether a link comes from a specific chromosome

e.g.

condition = from(mm10)

What you want is this

color =  eval(sprintf("chr%s",substr(var(chr1),2)))

1. var(chr1) will give you the start chromosome (e.g. mm10)
2. substr(mm10,2) will remove the first two characters to give 10
3. sprintf("chr%s",10) will give the string chr10
4. eval() evalutates the whole thing as code, which is required otherwise the instructions will be treated as a string

Alternatively, you can create color name aliases to have colors named the same as mouse chromosomes. In circos.conf

<colors>
mm1 = chr1
mm2 = chr2
...
</colors>

Once these are defined, the rule color can be

color = eval(var(chr1))

In other words, you don't have to jump through hoops to transform mm10 -> chr10.

> r1   = 1r+200p
> r0   = 1r
> link_dims      = 0p,0p,270p,0p,10p

You're allowing only 200 pixels for the text track but are asking for a link line that occupies 280 pixels. Turn off links and make the font smaller.

M


Martin Krzywinski
science + art



--
You received this message because you are subscribed to the Google Groups "Circos" group.
To unsubscribe from this group and stop receiving emails from it, send an email to circos-data-visual...@googlegroups.com.
To post to this group, send email to circos-data-...@googlegroups.com.
Visit this group at http://groups.google.com/group/circos-data-visualization.
For more options, visit https://groups.google.com/d/optout.

Chiara C

unread,
Jul 4, 2014, 4:21:13 AM7/4/14
to circos-data-...@googlegroups.com
Dear Martin,

thank you very much for the quick support.

I tried both your solutions for the color issue, but they do not seem to work. I attach part of the final output I get (I apologize, but I can't publish the whole picture, because it comes from proprietary data which I do not own).

The code I used to generate this output is show at the bottom of this message. Note that I had the same output even when I tried the first solution, therefore there surely is some error somewhere in my code which I am not able to find.

Regarding the labels problem, they are so overlapped that reducing the text enough to show all them makes them totally unreadable. However, I think this is an intrinsic problem of my data and I guess there is no real solution to it.

Thanks again,


Chiara



Code:


<<include etc/colors_fonts_patterns.conf>>

<<include ideogram.conf>>
#<<include ticks.conf>>

<colors>
mm1 = chr1
mm2 = chr2
mm3 = chr3
mm4 = chr4
mm5 = chr5
mm6 = chr6
mm7 = chr7
mm8 = chr8
mm9 = chr9
mm10 = chr10
mm11 = chr11
mm12 = chr12
mm13 = chr13
mm14 = chr14
mm15 = chr15
mm16 = chr16
mm17 = chr17
mm18 = chr18
mm19 = chr19
mmX = chr20
mmY = chr21
</colors>



<image>
<<include etc/image.conf>>
#radius* = 2100p
</image>

chromosomes_units           = 1000000
chromosomes_display_default = yes

# specify the karyotype file here - try other karyotypes in data/karyotype
karyotype = data/karyotype/karyotype.mouse.mm10.txt


<links>

z             = 0
radius        = 0.975r
bezier_radius = 0.2r



<link>
bezier_radius = undef
show          = yes
#color           = black_a5

thickness     = 4
file          = LINEAR_trans_no_covariates_circos.txt
record_limit  = 5000


<rule>
condition      =  1
# WRONG ROW:
color =  eval(var(chr1))

</rule>

</link>



</links>




<plots>
type       = text
color      = black
label_font = default
#label_size = 30p

<plot>
file = LINEAR_trans_no_covariates_etichette2_circos.txt
r1   = 1r+270p

r0   = 1r
label_size = 35p
show_links     = yes
link_dims      = 0p,0p,270p,0p,10p
link_thickness = 3p
link_color     = red
ticks_separation = 0.2p
</plot>


<plot>
file = LINEAR_trans_no_covariates_etichette3_circos.txt

r1   = 1r+200p
r0   = 1r
label_size = 30p

Chiara C

unread,
Jul 4, 2014, 4:24:59 AM7/4/14
to circos-data-...@googlegroups.com
I forgot to attach the picture:
circus_example.png

Martin Krzywinski

unread,
Jul 4, 2014, 2:06:25 PM7/4/14
to circos-data-...@googlegroups.com
You are missing the outer <rules> block

<rules>
<rule>
...
</rule>
</rules>



Martin Krzywinski
science + art



--

Chiara C

unread,
Jul 14, 2014, 8:00:59 AM7/14/14
to circos-data-...@googlegroups.com
Thank you Martin, it worked!
To unsubscribe from this group and stop receiving emails from it, send an email to circos-data-visualization+unsub...@googlegroups.com.

Silvia Turco

unread,
Sep 4, 2022, 4:38:21 PM9/4/22
to Circos
Hi guys,

I have three genomes, different isolates of the same fungal species, which chromosomes/contigs are indicated in the circos.sequences.txt as seq1 -> seq47 (so I would need 47 different colors and thus, I am using the Luminance-corrected chromosome palettes (lum70chr* from circos colors.ucsc.config file). 
I used Sibelia to create syntony block to be visualized with Circos but I want to adjust something in the picture.
First of all, I would like to color the links starting from the same chromosomes/contigs with the same color, as Chiara asked years ago.
I followed Martin's suggestions but there is something wrong.

## case 1: using color =  eval(sprintf("chr%s",substr(var(chr1),2)))  (in my case with lum70chr*)

My code would be:
karyotype = circos.sequences.txt
chromosomes_units = 1000000

<ideogram>
    <spacing>
        default = 0.003r

<pairwise seq10 seq11>
spacing = 1u
</pairwise>

<pairwise seq26 seq27>
spacing = 1u
</pairwise>

<pairwise seq47 seq1>
spacing = 1u
</pairwise>
    </spacing>

    radius    = 0.75r
    thickness = 180p
    fill      = yes
    stroke_color = black
    stroke_thickness = 5p
    show_label       = yes
    label_font       = default
    label_size       = 14
    label_parallel   = yes
</ideogram>

show_ticks*       = yes
show_tick_labels* = yes
show_grid = yes*

<links>
    crest = 1
    bezier_radius = 0.3r
    bezier_radius_purity = 1.0
    <link>
        show = yes
        ribbon = yes
        stroke_color = vdgrey
        stroke_thickness = 2
        file           = circos.segdup.txt
        radius        = 0.79r
        #color         = red_a4
        thickness     = 15
<rules>
<rule>
condition = from(seq1)
color = eval(sprintf("lum70chr%s",substr(var(chr1),3)))
</rule>
</rules>
    </link>
</links>

################################################################
# The remaining content is standard and required. It is imported
# from default files in the Circos distribution.
#
# These should be present in every Circos configuration file and
# overridden as required. To see the content of these files,
# look in etc/ in the Circos distribution.

<image>
<<include circos.image.conf>>
</image>

# RGB/HSV color definitions, color lists, location of fonts, fill patterns.
# Included from Circos distribution.
<<include etc/colors_fonts_patterns.conf>>

# Debugging, I/O an dother system parameters
# Included from Circos distribution.
<<include etc/housekeeping.conf>>

<highlights>
    fill_color = green
    <highlight>
        file = circos.highlight.txt
        ideogram = no
        fill_color = blue_a3
        stroke_color = black
        stroke_thickness = 4
        r0 = 1r -200p
        r1 = 1r -250p
    </highlight>
   
</highlights>
<ideogram>
    label_radius = 1r + 400p
</ideogram>


And the output is Figure-case1 below: from each ideogram/chromosome/contigs start links with different colors
figure_case1_circos.png



#### case 2: assign a color to each chromosome/contigs from seq1 to seq 47 and then use color =  eval(var(chr1))
karyotype = circos.sequences.txt
chromosomes_units = 1000000

<ideogram>
    <spacing>
        default = 0.003r

<pairwise seq10 seq11>
spacing = 1u
</pairwise>

<pairwise seq26 seq27>
spacing = 1u
</pairwise>

<pairwise seq47 seq1>
spacing = 1u
</pairwise>
    </spacing>

    radius    = 0.75r
    thickness = 180p
    fill      = yes
    stroke_color = black
    stroke_thickness = 5p
    show_label       = yes
    label_font       = default
    label_size       = 14
    label_parallel   = yes
</ideogram>

show_ticks*       = yes
show_tick_labels* = yes
show_grid = yes*

<links>
    crest = 1
    bezier_radius = 0.3r
    bezier_radius_purity = 1.0
    <link>
        show = yes
        ribbon = yes
        stroke_color = vdgrey
        stroke_thickness = 2
        file           = circos.segdup.txt
        radius        = 0.79r
        #color         = red_a4
        thickness     = 15
<rules>
<rule>
condition = 1
color* = eval(var(chr1))
</rule>
</rules>
    </link>
</links>

################################################################
# The remaining content is standard and required. It is imported
# from default files in the Circos distribution.
#
# These should be present in every Circos configuration file and
# overridden as required. To see the content of these files,
# look in etc/ in the Circos distribution.

<image>
<<include circos.image.conf>>
</image>

# RGB/HSV color definitions, color lists, location of fonts, fill patterns.
# Included from Circos distribution.
<<include etc/colors_fonts_patterns.conf>>

# Debugging, I/O an dother system parameters
# Included from Circos distribution.
<<include etc/housekeeping.conf>>

<colors>
seq1=lum70chr1
seq2=lum70chr2
seq3=lum70chr3
seq4=lum70chr4
seq5=lum70chr5
seq6=lum70chr6
seq7=lum70chr7
seq8=lum70chr8
seq9=lum70chr9
seq10=lum70chr10
seq11=lum70chr11
seq12=lum70chr12
seq13=lum70chr13
seq14=lum70chr14
seq15=lum70chr15
seq16=lum70chr16
seq17=lum70chr17
seq18=lum70chr18
seq19=lum70chr19
seq20=lum70chr20
seq21=lum70chr21
seq22=lum70chr22
seq23=lum70chr23
seq24=lum70chrX
seq25=lum70chr24
seq26=lum70chrY
seq27=lum70chrM
seq28=lum70chr0
seq29=lum70chrUn
seq30=lum70chrNA
seq31=lum80chr1
seq32=lum80chr2
seq33=lum80chr3
seq34=lum80chr4
seq35=lum80chr5
seq36=lum80chr6
seq37=lum80chr7
seq38=lum80chr8
seq39=lum80chr9
seq40=lum80chr10
seq41=lum80chr11
seq42=lum80chr12
seq43=lum80chr13
seq44=lum80chr14
seq45=lum80chr15
seq46=lum80chr16
seq47=lum80chr17
</colors>

<highlights>
    fill_color = green
    <highlight>
        file = circos.highlight.txt
        ideogram = no
        fill_color = blue_a3
        stroke_color = black
        stroke_thickness = 4
        r0 = 1r -200p
        r1 = 1r -250p
    </highlight>
   
</highlights>
<ideogram>
    label_radius = 1r + 400p
</ideogram>


And I got the same picture with slightly different colors assigned:
figure_case2_circos.png

The final idea would be to color the highlights below the ideogram with the same links colors.
Any suggestion please?
Silvia
Reply all
Reply to author
Forward
0 new messages