@@ -48,6 +48,7 @@ API usage is described in each of the following sections in the [document](https
4848-  [ Chord Diagram] ( https://moshi4.github.io/pyCirclize/chord_diagram/ ) 
4949-  [ Radar Chart] ( https://moshi4.github.io/pyCirclize/radar_chart/ ) 
5050-  [ Circos Plot (Genomics)] ( https://moshi4.github.io/pyCirclize/circos_plot/ ) 
51+ -  [ Comparative Genomics] ( https://moshi4.github.io/pyCirclize/comparative_genomics/ ) 
5152-  [ Phylogenetic Tree] ( https://moshi4.github.io/pyCirclize/phylogenetic_tree/ ) 
5253-  [ Plot Tips] ( https://moshi4.github.io/pyCirclize/plot_tips/ ) 
5354
@@ -108,37 +109,42 @@ gbk_fetch_data = fetch_genbank_by_accid("NC_002483")
108109gbk =  Genbank(gbk_fetch_data)
109110
110111#  Initialize Circos instance with genome size
111- circos =  Circos(sectors = {gbk.name: gbk.range_size})
112+ sectors =  gbk.get_seqid2size()
113+ space =  0  if  len (sectors) ==  1  else  2 
114+ circos =  Circos(sectors, space = space)
112115circos.text(f " Escherichia coli K-12 plasmid F \n\n { gbk.name} " , size = 14 )
113- circos.rect(r_lim = (90 , 100 ), fc = " lightgrey"  , ec = " none"  , alpha = 0.5 )
114- sector =  circos.sectors[0 ]
115- 
116- #  Plot forward strand CDS
117- f_cds_track =  sector.add_track((95 , 100 ))
118- f_cds_feats =  gbk.extract_features(" CDS"  , target_strand = 1 )
119- f_cds_track.genomic_features(f_cds_feats, plotstyle = " arrow"  , fc = " salmon"  , lw = 0.5 )
120- 
121- #  Plot reverse strand CDS
122- r_cds_track =  sector.add_track((90 , 95 ))
123- r_cds_feats =  gbk.extract_features(" CDS"  , target_strand = - 1 )
124- r_cds_track.genomic_features(r_cds_feats, plotstyle = " arrow"  , fc = " skyblue"  , lw = 0.5 )
125- 
126- #  Plot 'gene' qualifier label if exists
127- labels, label_pos_list =  [], []
128- for  feat in  gbk.extract_features(" CDS"  ):
129-     start =  int (feat.location.start)
130-     end =  int (feat.location.end)
131-     label_pos =  (start +  end) /  2 
132-     gene_name =  feat.qualifiers.get(" gene"  , [None ])[0 ]
133-     if  gene_name is  not  None :
134-         labels.append(gene_name)
135-         label_pos_list.append(label_pos)
136- f_cds_track.xticks(label_pos_list, labels, label_size = 6 , label_orientation = " vertical"  )
137- 
138- #  Plot xticks (interval = 10 Kb)
139- r_cds_track.xticks_by_interval(
140-     10000 , outer = False , label_formatter = lambda  v : f " { v/ 1000 :.1f }  Kb " 
141- )
116+ 
117+ seqid2features =  gbk.get_seqid2features(feature_type = " CDS"  )
118+ for  sector in  circos.sectors:
119+     #  Setup track for features plot
120+     f_cds_track =  sector.add_track((95 , 100 ))
121+     f_cds_track.axis(fc = " lightgrey"  , ec = " none"  , alpha = 0.5 )
122+     r_cds_track =  sector.add_track((90 , 95 ))
123+     r_cds_track.axis(fc = " lightgrey"  , ec = " none"  , alpha = 0.5 )
124+     #  Plot forward/reverse strand CDS
125+     features =  seqid2features[sector.name]
126+     for  feature in  features:
127+         if  feature.location.strand ==  1 :
128+             f_cds_track.genomic_features(feature, plotstyle = " arrow"  , fc = " salmon"  , lw = 0.5 )
129+         else :
130+             r_cds_track.genomic_features(feature, plotstyle = " arrow"  , fc = " skyblue"  , lw = 0.5 )
131+ 
132+     #  Plot 'gene' qualifier label if exists
133+     labels, label_pos_list =  [], []
134+     for  feature in  features:
135+         start =  int (feature.location.start)
136+         end =  int (feature.location.end)
137+         label_pos =  (start +  end) /  2 
138+         gene_name =  feature.qualifiers.get(" gene"  , [None ])[0 ]
139+         if  gene_name is  not  None :
140+             labels.append(gene_name)
141+             label_pos_list.append(label_pos)
142+     f_cds_track.xticks(label_pos_list, labels, label_size = 6 , label_orientation = " vertical"  )
143+ 
144+     #  Plot xticks (interval = 10 Kb)
145+     r_cds_track.xticks_by_interval(
146+         10000 , outer = False , label_formatter = lambda  v : f " { v/ 1000 :.1f }  Kb " 
147+     )
142148
143149circos.savefig(" example02.png"  )
144150``` 
@@ -161,8 +167,8 @@ matrix_data = [
161167]
162168matrix_df =  pd.DataFrame(matrix_data, index = row_names, columns = col_names)
163169
164- #  Initialize Circos from matrix  for plotting Chord Diagram 
165- circos =  Circos.initialize_from_matrix (
170+ #  Initialize Circos instance  for chord diagram plot 
171+ circos =  Circos.chord_diagram (
166172    matrix_df,
167173    space = 5 ,
168174    cmap = " tab10"  ,
0 commit comments