GithubHelp home page GithubHelp logo

ponnhide / pycircos Goto Github PK

View Code? Open in Web Editor NEW
317.0 11.0 66.0 198.58 MB

python Circos

License: GNU General Public License v3.0

Python 100.00%
biopython circos circos-plot matplotlib phylogenetic-trees python visualization

pycircos's Introduction

pyCircos

Circos is one of the most popular software for visualizing genomic similarities and features. However, its execution process is complicated and requires multiple original config files for the visualizations. Additionally, Circos is written in Perl, which limits its integration with other software for biological analysis. On the other hand, Python has been applied for various biological software packages. Therefore, by combining these packages, researchers can complete most of the required analysis. Nevertheless, Python lacks a library for drawing Circos plots, even though Circos software has been developed for more than a decade. Here, we provide a python Matplotlib based circular genome visualization package '"pyCircos." Users easily and quickly visualize genomic features and comparative genome analysis results by specifying annotated sequence files such as GenBank files.

Join Our Team: Bioinformatics Researcher Wanted.

We are currently seeking a skilled researcher with expertise in bioinformatics to join our lab.
For more details and to apply, please visit the following URL.

Gallery

Dependencies

  • python 3.7later

Installation

For normal users, we recommended you to install the official release as follows.
pip install python-circos

If you want to use developmental version, it can be installed using the following single command:
pip install git+https://github.com/ponnhide/pyCircos.git

Usage

pyCircos provides the “Gcircle class” and "Garc class". A "Gcircle" class object holds the dictionary of Garc class objefcts and provides functions to place Garc classs object on the circular map. Each Garc class object manages numeric and genomic data to be visualized on the circular map.

News

Version 0.3.0 is released.

  • Tarc class and Tcircle class are added.
    Tarc class and Tcircle class is implemented as subclass of Garc and Gcircle class, respectivily.
    By using these class, you can draw circular phylogenetic tree as the following example.

You can execute the example code to draw the circular phylogenetic tee on the Google colab.

Version 0.2.0 is released. The `fig` parameter is added for Gcircle.__init__, so it is now possible to specify your own figure object.

If you want to arrange multiple circos plots, I reccomend to use patchworklib.
Please see the following example code.
https://colab.research.google.com/drive/1tkn7pxRqh9By5rTFqRbVNDVws-o-ySz9?usp=sharing

Example result of multiple circos plots

Gcircle class

A Gcircle class object provides a circle whose diameter is 1000 (a.u.) as a drawing space. Any graph (line plot, scatter plot, barplot, heatmap, and chordplot) can be placed on the space by specifying the raxis_range (from 0 to 1000) and the corresponding Garc class object.

Parameters

  • .garc_dict: dict (default:None) Dictionary of the Garc class objects in Gcircle object. The keys of the dictionary are id values of the Garc class objects.

  • .figsize: tuple (dfault:) Figure size for the circular map.

Methods

  • .add_garc (garc_object=Garc class object)
    Add a new Garc class object into garc_dict.

    • garc_object: Garc class object (default:None)
      Garc class object to be added.

    return None

  • .set_garcs(start=0, end=360)
    Visualize the arc rectangles of the Garc class objects in .garc_dict on the drawing space. After the execution of this method, a new Garc class object cannot be added to garc_dict and figure parameter representing maplotlib.pyplot.figure object will be created in Gcircle object. return None

    • start: int (defaut: 0)
      Start angle of the circos plot. The value range is -360 ~ 360.
    • end: int (default: 360)
      End angle of the circos plot. The value range is -360 ~ 360.
  • .lineplot (garc_id=str, data=list or numpy.ndarray , positions=list or numpy.ndarray, raxis_range=tuple, rlim=*tuple, linestyle=str, linecolor=str or tuple, linewidth=int)
    Plot a line in the sector corresponding to the arc of the Garc class object specified by garc_id.

    • garc_id: str (defaut: None)
      ID of the Garc class object. The ID shoud be in Gcircle object.garc_dict.
    • data: list or numpy.ndarray (default: None)
      Numerical data to be drawn with line.
    • positions: list or numpy.ndarray (default: None)
      The x coordinates of the values in data on the Garc class object when the plot is drawn on the rectangular coordinates. Each coordinate value should be in the range 0 to size of the Garc class object specified by garc_id. By the method execution, the coordinates are converted to proper angle coordinates. If positions are not given, proper coordinates values are generated according to the length of data.
    • raxis_range: tuple (top=int, bottom=int) (default: (550, 650))
      Radial axis range where line plot is drawn.
    • rlim: tuple (top=int, bottom=int) (default: (min(data), max(data)))
      The top and bottom r limits in data coordinates. If rlim value is not given, the maximum value and the minimum value in data will be set to top and bottom , respectively.
    • linestyle: str (default: "solid")
      Line style. Possible line styles can be reffered from https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html
    • linecolor: str or tuple representing color code (default: None)
      Color of the line plot. If linecolor value is not given, the color will be set according to the default color set of matplotlib. To specify the opasity for a line color, please use (r, g, b, a) or #XXXXXXXX format.
    • linewidth: float (default: 1)
      Line width.

    return None

  • .fillplot (garc_id=str, data=list or numpy.ndarray , positions=list or numpy.ndarray, raxis_range=tuple, rlim=tuple, base_value=float, facecolor=str or tuple, linecolor=str or tuple, linewidth=int)
    Fill a specified area in the sector corresponding to the arc of the Garc class object specified by garc_id.

    • garc_id :str (defaut: None)
      Same parameter with garc_id of lineplot().
    • data: list or numpy.ndarray (default: None)
      Same parameter with data of lineplot().
    • positions: list or numpy.ndarray (default: None)
      Same parameter with positions of lineplot().
    • raxis_range: tuple (top=int, bottom=int) (default: (550, 650))
      Same parameter with raxis_range of lineplot().
    • rlim: tuple (top=int, bottom=int) (default: (min(data), max(data))
      Same parameter with rlim of lineplot().
    • base_value: float (default: 0)
      Base line height in data coordinates. The area between the base line and the data line is filled by facecolor.
    • facecolor: str or tuple representing color code (default: None)
      Color for filling.
    • edgecolor: str or tuple representing color code (default: "#303030")
      Edge color of the filled area
    • linewidth: float (default: 0)
      Edge line width.

    return None

  • .scatterplot (garc_id=str, data=list or numpy.ndarray , positions=list or numpy.ndarray, raxis_range=tuple, rlim=tuple, markershape=str, facecolor=str or tuple, edgecolor =str or tuple, linewidth=int, markersize=int)
    Plot markers in the sector corresponding to the arc of the Garc class object specified by garc_id.

    • garc_id :str (defaut: None)
      Same parameter with garc_id of lineplot().
    • data: list or numpy.ndarray (default: None)
      Numerical data to be drawn by scatter plots.
    • positions: list or numpy.ndarray (default: None)
      Same parameter with positions of lineplot().
    • raxis_range: tuple (top=int, bottom=int) (default: (550, 650))
      Same parameter with raxis_range of lineplot().
    • rlim: tuple (top=int, bottom=int) (default: (min(data), max(data))
      Same parameter with rlim of lineplot().
    • makershape: str (default: "o")
      Marker shape. Possible marker shapes can be reffered from https://matplotlib.org/stable/gallery/lines_bars_and_markers/marker_reference.html.
    • markersize: float or list of float (default: None)
      Size(s) of the marker(s).
    • facecolor: str, tuple representing color code or list of color code (default: None)
      Face color(s) of the markers. If value type is list, the lenght of facecolor should be the same as the data length.
    • edgecolor: str or tuple representing color code (default: None)
      Edge color of the markers
    • linewidth: float (default: 0)
      Edge line width of the markers

    return None

  • .barplot (garc_id=str, data=list or numpy.ndarray , positions=list or numpy.ndarray, width=float or list, raxis_range=tuple, rlim=tuple, base_value=int, faceolor=str or tuple, edgecolor=str or tuple)

    Plot bars in the sector corresponding to the arc of the Garc class object specified by garc_id.

    • garc_id :str (defaut: None)
      Same parameter with garc_id of lineplot().
    • data: list or numpy.ndarray (default: None)
      Numerical data to be drawn by bar plots.
    • positions: list or numpy.ndarray (default: None)
      Same parameter with positions of lineplot(). The center of the base bases become in positions.
    • width: float or list of float (default: garc_object.size/len(data))
      Width(s) of the bars.
    • raxis_range: tuple (top=int, bottom=int) (default: (550, 650))
      Same parameter with raxis_range of lineplot().
    • rlim: tuple (top=int, bottom=int) (default: (min(data), max(data))
      Same parameter with rlim of lineplot().
    • facecolor: str, tuple representing color code or list of color code (default: None)
      Facecolor(s) of the bars. If value type is list, the lenght of facecolor should be the same as the data length.
    • edgecolor: str or tuple representing color code (default: None)
      Edge color of the bars
    • linewidth: float (default: 1.0)
      Edge line width of the bars.

    return None

  • .heatmap (garc_id=str, data=list or numpy.ndarray, positions=list or numpy.ndarray, width=float or list, raxis_range=tuple, cmap=str, vmin=float, vmax=float)
    Visualize magnitudes of data values by color scale in the sector corresponding to the arc of the Garc class object specified by garc_id.

    • garc_id :str (defaut: None)
      Same parameter with garc_id of lineplot().
    • data: list or numpy.ndarray (default: None)
      Numerical data to be visualized by color scale. Two dimensional array can also be taken.
    • positions: list or numpy.ndarray (default: None)
      Same parameter with positions of lineplot().
    • width: float or list of float (default: garc_object.size/len(data))
      Width(s) of the bars.
    • raxis_range: tuple (top=int, bottom=int) (default: (550, 650))
      Same parameter with raxis_range of lineplot()
    • cmap: str represeting matplotlib colormap name or matplotlib.colors.Colormap object (default: "Reds")
      The mapping from data values to color space.
    • vmin: float (default: min(data))
      Minimum data limit for color scale.
    • vmax: float (default: min(data))
      Maximum data limit for color scale.

    return None

  • .chordplot(arc_loc1=tuple, arc_loc2=tuple, facecolor=str or tuple, edgecolor=str or tuple, linewidth=int) Visualize inter-relation ships between data.

    • arc_loc1: tuple (defaut: None)
      First data location of linked data. The tuple is composed of four parameters: arc_id, ede_position1, edge_position2, raxis_position
      edge_position1 and edge_position2 are the x coordinates on the Garc class object when the plot is drawn on the rectangular coordinates.
      raxis_position is base height for the drawing cord.
    • arc_loc2: tuple (defaut: None)
      Second data location of linked data.
    • facecolor: str or tuple representing color code (default: None)
      Face color of the link.
    • edgecolor: str or tuple representing color code (default: None)
      Edge color of the link.
    • linewidth: float (default: 0.0)
      Edge line width of the link.

    return None

  • .featureplot (garc_id=str, feature_type=str, soruce=list of Bio.SeqFeature object, raxis_range=tuple, faceolor=str or tuple)
    Visualize sequence features with bar plots in the sector corresponding to the arc of the Garc class object specified by garc_id.

    • garc_id :str (defaut: None)
      Same parameter with garc_id of lineplot().
    • feature_type: str (default: "all")
      Biological nature of the Bio.Seqfeature class objects (Any value is acceptable, but GenBank format requires registering a biological nature category for each sequence feature).
      If the value is "all",all features in soruce will be drawn in the sector of the Garc class object specified by grac_id.
    • source: list of Bio.SeqFeature object (default: record.features of the Garc class object specified by grac_id )
      List of Bio.Seqfeature class object. If source value is not given, record.features of the Garc class object specified by grac_id is given.
    • raxis_range: tuple (top=int, bottom=int) (default: (550, 650))
      Same parameter with raxis_range of lineplot().
    • facecolor: str or tuple representing color code (default: None)
      Face color of the feature bars.

    return None

Tcircle class

Tcircle class is the subclass of Gcircle. All methods implemented in the Gcircle class also can be used. Then, the two additional methods set_tarc, plot_tree and plot_highlight is provided in the Tcircle class.

Methods

  • .add_tarc(tarc=str): Add a new Tarc or Garc class object into tarc_dict.

    • tarc : Tarc class object (default:None) Tarc class object to be added.

    return None

  • .plot_tree(tarc_id=str, rlim=tuple, cladevisual_dict=dict, highlight_dict=dict, linecolor=str, linewidth=float):
    Drawa circular phylogenetic tree.  - tarc_id: str ID of the Tarc class object. The ID should be in Tcircle

    • object.tarc_dict: dict
    • rlim : tuple (top=int, bottom=int) The top and bottom r limits in data coordinates. The default vlaues is (0, 700). If the first value is less than second value, tree will be outward direction. If the first value is larger than second value, tree will be inward direction.
    • cladevisual_dict : dict Dictionay composed of pairs of clade name and a sub-dict holding parameters
      to visualize the clade. A sub-dict is composed of the following key-value pairs:
      • size: int or float Size of dot. The default value is 5.
      • color: float or str replresenting color code.
        Face color of dot. The default value is '#303030'.
      • edgecolor: float or str replresenting color code.
        Edge line color of dot. The default value is '#303030'.
      • linewidth: int or float. Edge line width of dot. The default value is 0.5.

    return None

  • .plot_tree(tarc_id=str, highlight_dict=dict):
    Add highlight for specif clade under the given internal clade.

    • highlight_dict: dict
      Dictionay composed of pairs of internal clade name and a sub-dict.
      Instead of clade name, tuples of teminal clade names can also be used. A sub-dict is composed of the following key-value pairs:
      • color: str
        Color of highlight for clades. The default value is "#000000".
      • alpha: flaot
        Alpha of highlight for clades. The default vlalue is 0.25.
      • label: str
        Label. The default vlalue is None.
      • fontsize: int or float
        Fontsize of label. The default vlalue is 10.
      • y: int or float
        Y location of the text. The default vlalue is the bottom edge of the highliht.

    return None

Garc class

A Garc class object can be created by Garc() command.
The following parameters, which are mainly used for the visualization of the arc rectangle, can also be specified.

Parameters

  • arc_id: str (default None)
    Unique identifier for the Garc class object. Suppose id value is not given. An original unique ID is automatically given for Garc object.
  • record: Bio.SeqRecord class object or NCBI accession number (default: None)
    Bio.SeqRecord class object or NCBI accession number of an annotated sequence. If a NCBI accession number is given, the GeBank reord of the accesion number will be loaded from NCBI public database.
  • size: float (default: 1000)
    Width of the arc rectangle. If record is given, the value is set by the sequence length of the record. The real arc rectangle width in the circle is determined by the ratio of size to the sum of the size and interspace values of the Garc class objects in the Gcircle class object.
  • interspace: float (default: 0)
    Distance angle to the adjacent arc rectangle on the right. The real interspace size in the circle is determined by the ratio of size to the sum of the size and interspace values of the Garc class objects in the Gcircle class object.
  • raxis_range: tuple (top=int, bottom=int) (default: (500, 550))
    Radial axis range where the arc rectangle is drawn.
  • facecolor: str or tuple representing color code (default: None)
    Face color for the arc rectangle. If facecolor is not given, the color will be selected from the default color set provided in the pyCircos module.
  • edgecolor: str or tuple representing color code (default: "#303030")
    Edge color for the arc rectangle. If edgecolor is not given, the color will be selected from the default color set provided in the pyCircos module.
  • linewidth: int (default: 0)
    Edge line width of the arc rectangle.
  • label: str (default: arc_id)
    Label of the arc rectangle.
  • labelposition: int (default:0)
    Relative label height from the center of the arc rectangle.
  • labelsize: int (default:0)
    Font size of the label.
  • label_visible: bool (defaule: False)
    If True, label of the Garc object is shown on the arc rectangle.

Methods

The Garc class object provides some analytical methods to support users analyze genomic characters.

  • .calc_density(positions=list, window_size=int)
    Converts positions consisting of x-coordinates into a list of density values scanned in a sliding window.

    • positions: list of int or tuple
      List of x corrdinate values or tuple consisting of two x coordinate values. Each coordinate value should be in the range 0 to size of Garc object.
    • window_size: int (default:1000)
      Size of the sliding window

    return list consisting of density values

  • .calc_nnratio(n1=str, n2=str, window_size=int, step_size=int)
    n1 and n2 are one of the nucleotide base letters of "ATGC". Calculate n,m ratiio for multiple windows along the sequence. If Garc object.record is None, the method will not work.

  • .calc_nnskew(n1=str, n2=str, window_size=int, step_size=int)
    n1 and n2 are one of the nucleotide base letters of "ATGC". Calculate n,m skew (n-m)/(n+m) for multiple windows along the sequence. If Garc object.record is None, the method will not work.

Example code

Prease see the notebooks in the 'tutorial' directrory. I also provide the executable tutorial codes in Google Colaboratory.

pycircos's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pycircos's Issues

Plotting gene density

Hey,

thanks for this nice package, really cool to see a working implementation for circos plots in Python.

My question:
Is it possible to also plot the gene density across the whole genom inside a circos plot?

Thanks in advance ;)

Implementation of original Circos style ticks label plot function

Hi,

Thank you for developing a very nice Circos plotting tool implemented in Python.

pyCircos currently implements a tickplot function to plot ticks on a Garcs object, but it does not support tick label plotting in the original Circos style as shown below.

gallery_result02

Since tick plots like the one shown above are often used, I think pyCircos would be better off if this function is implemented.

Adding text inside each arc in a circle

Hello @ponnhide,

I'm trying to plot a circos diagram (like the one here) using pycircos.

I tried to do the first arc following the tutorials. I am trying to understand how to add text in each arc.

Code:

import pandas as pd
import pycircos
import matplotlib.pyplot as plt

Garc = pycircos.Garc
Gcircle = pycircos.Gcircle

d = {
    'A': ['study1', 'study2', 'study3'],
    'B': ['study1', 'study4', 'study5'],
    'C': ['study1', 'study2']
}

circle = Gcircle(figsize=(8, 8))
# add keys
for name in d.keys():
    print(name)
    arc = Garc(arc_id=name, interspace=0, raxis_range=(935, 985), labelposition=80, label_visible=True)
    circle.add_garc(arc)
circle.set_garcs(-65, 245)
for arc_id in circle.garc_dict:
    circle.tickplot(arc_id, raxis_range=(985, 1000), tickinterval=20000000, ticklabels=None)
circle.figure
circle.figure.savefig("test.png")

Plot:

enter image description here

I would like to add text (i.e. values stored in d, the keys are the arcs) to each arc in the next level circle or inside each arc in the current circle. Example figure is available here.

Suggestions on how to do this will be of great help.

Thanks a lot for the wonderful library!

Add opacity?

Is it possible to add opacity to the chord plots?

Locus labeling

Hey,

trying out this cool circos plots i figured it would be helpful to be able to label the specified locus in the plot. These plots would be perfect for a project of mine.
So i noticed the individual locusses can be given a name, but can this name be displayed in the actual plot then also?
Or could one insert a legend in the corner of the plot, labeling all locusses by their color and name?

Because playing round with the tutorial script i could only change locus coordinates, color, but changing the name would still not show any name.

Thanks for advice,

Valentin

tickplot/barplot not respecting genome coordinates or value

I have a viral genome for which I want a circos plot with the genes as outer circle, CDS (+/-) and an histogram/barplot for counts of novel orfs.

Looking at the data format in the example repo

seems that something like this should suffice

gene start end value novel
gene1 163 553 0.3 novel
gene2 516 1101 0.5 reported
gene3 1581 2103 0.1 novel

However, when I use this table to generate the figure:

  • the barplot is not correct (i.e has same length and no colors)
  • the tickplot is not correct (I have CDS everywhere but it is subsetted to only a region?)
Garc  = pycircos.Garc
    Gcircle = pycircos.Gcircle
    circle = Gcircle(figsize=(8,8)) 
    for gn in set(tots['gene']):
        subs = tots[tots['gene']==gn]        
        arc    = Garc(arc_id=gn, size=int(subs['end']), interspace=2, raxis_range=(935,985), labelposition=80, label_visible=False)
        circle.add_garc(arc) 
    circle.set_garcs(-65, 245)
    for arc_id in circle.garc_dict:
        circle.tickplot(arc_id, raxis_range=(985,1000), tickinterval=100000000, ticklabels=None) 
    arcdata_dict = collections.defaultdict(dict)
    tots['start'] = tots['start'].astype(int)-1
    for gn in set(tots['gene']):
        subs = tots[tots['gene']==gn]
        arcdata_dict[gn]['positions'] = list(subs['start'])
        arcdata_dict[gn]["widths"] = list(
            subs['start'].astype(int) - subs['end'].astype(int))
        arcdata_dict[gn]["values"] = list(subs['value'].astype(float))
        print(list(subs['value'].astype(float)))
    values_all = list(tots['value'])
    vmin, vmax = min(values_all), max(values_all)
      cols = ['white' if 'reported' in x else 'purple' for x in tots['novel']]
    for key in arcdata_dict:
        circle.barplot(key, data=arcdata_dict[key]["values"], positions=arcdata_dict[key]["positions"],
                        width=arcdata_dict[key]["widths"], base_value=0.0, rlim=[vmin-0.05*abs(vmin), vmax+0.05*abs(vmax)],
                        raxis_range=[500, 745], facecolor=cols, spine=True)

If I do

    for key in arcdata_dict:
        print(arcdata_dict[key]["values"], arcdata_dict[key]["widths"])

The various bars have different width and different heights.

see results here
test.pdf

using a GB file as input as the tutorial #2

If I use a gb file as Garc the barplot is also not correct

    f    Garc = pycircos.Garc
    Gcircle = pycircos.Gcircle
    record = SeqIO.read(base, format="genbank")
    garc = Garc(arc_id=id, record=record, interspace=0, linewidth=0,
                facecolor="#FFFFFF00", raxis_range=(0, 10),
                label="my org", label_visible=True)
    gcircle = Gcircle()
    gcircle.add_garc(garc)
    gcircle.set_garcs()

    plus_CDS = []
    minus_CDS = []
    for feat in garc.record.features:
        if feat.type == "CDS" and feat.strand >= 0:
            plus_CDS.append(feat)
        elif feat.strand == -1:
            minus_CDS.append(feat)
    gcircle.featureplot(id, source=plus_CDS,
                        raxis_range=(700, 750), facecolor="tomato")
    gcircle.featureplot(id, source=minus_CDS,
                        raxis_range=(750, 800), facecolor="cornflowerblue")


    arcdata_dict = collections.defaultdict(dict)
    tots['start'] = tots['start'].astype(int)-1
    arcdata_dict[id]['positions'] = list(tots['start'])
    arcdata_dict[id]["widths"] = list(
        tots['start'].astype(int) - tots['end'].astype(int))
    arcdata_dict[id]["values"] = list(tots['value'].astype(float))
    values_all = list(tots['value'])

   # highlight novel ORFs
    cols = ['white' if 'reported' in x else 'purple' for x in tots['novel']]

    vmin, vmax = min(values_all), max(values_all)
    for key in arcdata_dict:
        gcircle.barplot(key, data=arcdata_dict[key]["values"], positions=arcdata_dict[key]["positions"],
                        width=arcdata_dict[key]["widths"], base_value=0.0, rlim=[vmin-0.05*abs(vmin), vmax+0.05*abs(vmax)],
                        raxis_range=[500, 745], facecolor=cols, spine=True)

Zooming in the barplot, there are black bars but no purple bars (while the CDS distribution looks correct).

test_CDS.pdf

    print(len([x for x in cols if x=='purple']))
   # print 4

Am I missing something fundamental here?

The input file is build using the same GenBank file so I am not sure why there are missing regions in the tick plot.

How are the ID's linked to the Phyla for the phylogenetic tree example?

Hey, this looks like a very useful code set. Thanks for your effort here.

I would like to customize this for my use, but from the example (without any comments) I am unclear how the highlight_dict for tree-2.pdf links to the previous tree. It looks like for tree-1.pdf the ID column is the same as the branch label of the nwk file, but I don't follow where the phyla names are retained.

Could you explain how the dictionaries are linked between the different tree examples?

Thank you,
Roth

Saving a plot

Hi,

thanks for developing and maintaining pyCircos, looks very promising. I tried to reproduce your tutorial locally:

`

    import pycircos
    import matplotlib.pyplot as plt
    Garc  = pycircos.Garc
    Gcircle = pycircos.Gcircle

    #Set chromosomes
    circle = Gcircle()
    with open("test.csv") as f:
        f.readline()
        for line in f:
            line = line.rstrip().split(",")
    
            name = line[0]
            length = int(line[-1])
    
            arc  = Garc(arc_id=name, size=length, interspace=3, raxis_range=(950,1000), labelposition=60, label_visible=True)
    
            circle.add_garc(arc)
    
    circle.save()`

"test.csv" contains the data of example_data_chromosome_general.csv. The PDF file is empty, do you have any ideas what I did wrong?

I am working on Windows 10 and installed pyCircos via pip.

Thanks a lot!
Stefanie

Within-code docstrings?

I've noticed that the code in pycircos.py and noticed that the current version of this file doesn't include within-code doc-strings for the relevant definitions. However, the readme document features a very comprehensive and useful documentation of these (that is also PEP 8 / 257 compliant?)

Is this an intentional omission? Alternatively, would you be interested in someone transcribing these in the pertinent locations? There may well be an automated method for doing this (or an alternate version with this already done), but if not, I could produce a version with this as I work through commenting my fork of the code (attempting to make variations for neuroscience-related applications).

Chord_plot coordinates

Hi,

Pretty handy tool you have developed here. It is a good alternative to R circos plot tools.

I have a question: in the chord_plot function, the edge_position1 and edge_position2 are the x coordinates on the Garc class object, but where can I get those from? I've been inspecting the object but I can't seem to get those. I noticed in you tutorials that you have an input file with those edge_position1 and edge_position2 data points, but where did you get those from?

Thanks for your feedback

arrows for edges?

Hi, thanks for this really great package! I'm trying to incorporate the chord diagrams as a way to visualise cellular interactions.

So far it's great and i manage to create a plot that looks like:
image

I was wondering if there's a way to plot the edges as arrows intead of just lines at the moment?

Should pyCircos be published to somewhere?

pyCircos was a kind of throwaway code generated in my research.
Therefore, the repository was just a note for me.
However, some people started to give a star to the repository, and contributors provided valuable modifications for the pyCircos functions and documents.
Now, the repository has over 100 stars, and I found that pyCircos (the old version) is used in a scientific publication. (https://bmcbioinformatics.biomedcentral.com/articles/10.1186/s12859-021-04348-5).
However, pyCircos itself is not published in any scientific publications, so users cannot cite pyCircos formally when using it.

Here, I want to ask the following things the pyCircos users.

Do you hope pyCircos to take some guarantee from a peer-reviewed scientific publication?
In the first place, does pyCircos have any value or novelty to be published from such sources?

If you hope it and think pyCircos has some value, I will consider submitting pyCircos to a bioinformatics journal.
If you have any ideas or comments, please post them here.

Thank you for reading ot.

Issue with plotting CDS

Dear

I tried to follow tutorial 2 on the example dataset and whenever plotting the CDS, I receive following error message. I have tried to resolve it myself without success.


AttributeError Traceback (most recent call last)
in <cell line: 9>()
7 elif feat.strand == -1:
8 minus_CDS.append(feat)
----> 9 gcircle.featureplot("NC_000913", source=plus_CDS, raxis_range=(700,780), facecolor="tomato")
10 gcircle.featureplot("NC_000913", source=minus_CDS, raxis_range=(780,860), facecolor="cornflowerblue")

/content/pycircos/pycircos.py in featureplot(self, garc_id, feature_type, source, raxis_range, facecolor, edgecolor, linewidth, spine)
1034 for feat in feature_list:
1035 if feat.location.strand >= 0:
-> 1036 s = int(feat.location.parts[0].start.position)
1037 e = int(feat.location.parts[-1].end.position)
1038 pos = start + ((end-start) * s/size)

AttributeError: 'ExactPosition' object has no attribute 'position'

Thank you in advance!

Y axis labels

Is it possible to label y axis, for example with a scatterplot?

Suggestions for Improvements of API Documentation

Hi, ponnhide

Currently, the API documentation is in the README, and its content is roughly the same as the docstring (by @DanNBullock work #8). However, the API documentation in the README is difficult for users to reference, and it seems generally not a good practice to manually write the specifications separately in both the API documentation and the docstring. To solve this problem, how about automatically generating an HTML-format API document from the docstring and hosting it on GitHub Pages?

Using pdoc3, you can easily generate HTML-format API documentation from docstrings in your code.

pip install pdoc3
pdoc3 ./pycircos -o ./pycircos_api_docs --html --force \
      -c list_class_variables_in_index=False -c sort_identifiers=False

Example API docs: pycircos_api_docs.zip (:warning: some display is broken, docstring needs a little fixing)

After the automatic generation of HTML API docs, you can publish them to your users by simply placing the generated docs in a directory in your repository where GitHub Pages is enabled.

Example: GitHub Pages / Repo (<= I'll delete this example page in a few weeks)

You can also configure GitHub Actions to automatically update the API docs after a Push/Pull-Request to GitHub, if you are interested in trying this. If needed, I can provide an automated API docs generation workflow with GitHub Actions that I use.

The following article may be helpful (in Japanese).

Best Regards,

pyCircos implementation

Hello! i'd like to implement pyCircos into my Tool, but I do not manage to do it with the given doc. I can't even run the example scripts. Would you mind helping me out?

Tickplot examples?

Hi, I'm really struggling to get labels oriented by 90 degrees. The previous issue has been closed as tickplot implemented. Are there any working examples of this please?

(very nice lib by the way, thank you for having created it).

Bug class Gcircle(object):

Dear authors,

Class definition in python is without parenthesis. Line 22 on pycircos.py shows like this:

class Gcircle(object):

But it should be without the parenthesis:

class Gcircle:

Changing this, the package goes smooth.

Thanks for this tool.

Best,
Juanlu.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.