jdgenometracks


Namejdgenometracks JSON
Version 0.2.1 PyPI version JSON
download
home_pageNone
SummaryA Python package for plotting genomic data.
upload_time2024-09-11 17:43:29
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # **jdgenometracks**

## Overview

**jdgenometracks** is a Python package designed to simplify the visualization of genomic data using **Plotly** and **Matplotlib**. The package supports visualizing different track types such as **BED**, **BEDGRAPH**, and **axis** tracks, making it ideal for managing and plotting large genomic datasets with customizable visual styles.

At the core of the package is the **TrackFactory**, which allows users to easily create and manage genomic tracks, enabling the use of both Plotly and Matplotlib with the same set of track definitions.

## Key Features

- **TrackFactory** for easy creation of tracks (e.g., BED, BEDGRAPH, axis, and spacer tracks).
- Supports **Plotly** and **Matplotlib** visualization.
- Customizable plotting options (e.g., colors, markers, lines).
- Easily handle large genomic datasets and visualize them in multiple columns or rows.

## Installation

```bash
pip install jdgenometracks
```

## Getting Started

### Example: Creating and Plotting Tracks with Plotly

```python
import jdgenometracks as jdg

# Define a set of tracks to visualize
tracks = [
    jdg.TrackFactory.create_track(
        file_path="example_data/track1.bedgraph",
        track_name="Track 1",
        track_type="bedgraph",
        plot_type="points",
        plotly_options={
            "marker_color": "blue",
            "marker_size": 4
        }
    ),
    jdg.TrackFactory.create_track(
        file_path="example_data/track2.bed",
        track_name="Track 2",
        track_type="bed",
        plotly_options={
            "fillcolor": "red",
            "line_color": "black"
        }
    ),
    jdg.TrackFactory.create_track(
        track_name="Bottom Axis",
        track_type="axis",
        axis_type="verbose"
    )
]

# Now, pass these tracks to a Plotly plotting utility (example):
plotter = jdg.PlotlyPlotter(tracks, total_height=800)
fig = plotter.plot_all_tracks(column_titles=["Sample Data"])
fig.show()
```

### Example: Creating and Plotting Tracks with Matplotlib

```python
import jdgenometracks as jdg

# Define a set of tracks for Matplotlib
tracks = [
    jdg.TrackFactory.create_track(
        file_path="example_data/track1.bedgraph",
        track_name="Track 1",
        track_type="bedgraph",
        plot_type="lines",
        mpl_plot_options={
            "color": "blue",
            "linewidth": 2
        }
    ),
    jdg.TrackFactory.create_track(
        file_path="example_data/track2.bed",
        track_name="Track 2",
        track_type="bed",
        mpl_rect_options={
            "color": "red",
            "linewidth": 2
        },
        mpl_text_options={
            "va": "center"
        },
        mpl_text_alignment="right"
    ),
    jdg.TrackFactory.create_track(
        track_name="Bottom Axis",
        track_type="axis",
        axis_type="verbose"
    )
]

# Use a Matplotlib plotter
plotter = jdg.MPLPlotter(tracks, total_height=8)
fig, axes = plotter.plot_all_tracks(plot_title="Genomic Data")
plt.show()
```

### Example: Displaying Two Columns of Tracks with Plotly

```python
import jdgenometracks as jdg
import numpy as np

# Define two sets of tracks to display in two columns
tracks = [
    # First Column (Column 1)
    jdg.TrackFactory.create_track(
        file_path="example_data/track1_column1.bedgraph",
        track_name="Track 1 - Column 1",
        track_type="bedgraph",
        plot_type="points",
        plotly_options={
            "marker_color": "blue",
            "marker_size": 4
        }
    ),
    jdg.TrackFactory.create_track(
        file_path="example_data/track2_column1.bed",
        track_name="Track 2 - Column 1",
        track_type="bed",
        plotly_options={
            "fillcolor": "red",
            "line_color": "black"
        }
    ),
    jdg.TrackFactory.create_track(
        track_name="Bottom Axis - Column 1",
        track_type="axis",
        axis_type="verbose"
    ),

    # Second Column (Column 2)
    jdg.TrackFactory.create_track(
        file_path="example_data/track1_column2.bedgraph",
        track_name="Track 1 - Column 2",
        track_type="bedgraph",
        plot_type="lines",
        plotly_options={
            "line_color": "green",
            "line_width": 2
        }
    ),
    jdg.TrackFactory.create_track(
        file_path="example_data/track2_column2.bed",
        track_name="Track 2 - Column 2",
        track_type="bed",
        plotly_options={
            "fillcolor": "purple",
            "line_color": "black"
        }
    ),
    jdg.TrackFactory.create_track(
        track_name="Bottom Axis - Column 2",
        track_type="axis",
        axis_type="verbose"
    )
]

# Reshape the tracks to 2 columns (first 3 tracks in column 1, next 3 in column 2)
tracks = np.array(tracks).reshape(-1, 2)

# Plot using PlotlyPlotter
plotter = jdg.PlotlyPlotter(tracks, total_height=800)
fig = plotter.plot_all_tracks(
    column_titles=["Column 1", "Column 2"],  # Titles for each column
    height_props=[1, 1, 0.1],  # Proportions for each row (tracks and axis)
    width_props=[1, 1]  # Equal width for both columns
)

# Display the figure
fig.show()
```

## TrackFactory Usage

The **TrackFactory** allows you to create different types of tracks. Here are some examples of how to use the factory to create tracks:

### BEDGRAPH Track

```python
jdg.TrackFactory.create_track(
    file_path="path/to/file.bedgraph",
    track_name="Example BEDGRAPH",
    track_type="bedgraph",
    plot_type="lines",
    plotly_options={
        "line_color": "green",
        "line_width": 2
    }
)
```

### BED Track

```python
jdg.TrackFactory.create_track(
    file_path="path/to/file.bed",
    track_name="Example BED",
    track_type="bed",
    plotly_options={
        "fillcolor": "purple",
        "line_width": 2
    }
)
```

### Axis Track

```python
jdg.TrackFactory.create_track(
    track_name="X-Axis",
    track_type="axis",
    axis_type="verbose"
)
```

## Customizing Plots

Each track can be customized using **Plotly** keyword arguments or **Matplotlib** keyword arguments. Example options include:

- **Colors**: Set line and marker colors.
- **Line Styles**: Adjust line widths and types.
- **Markers**: Control marker styles (e.g., size, symbol).
- **Axes**: Customize axis labels and ticks.

## Advanced Usage

For more advanced use cases, you can extend the package to support new track types or customize existing ones by modifying the `TrackFactory` to handle additional parameters or features.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "jdgenometracks",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Justin Delano <jdelano@g.harvard.edu>",
    "download_url": "https://files.pythonhosted.org/packages/6c/9e/8f75f4e39b391262e855101ff4b5821274e502813b0808fd158f0136ccbe/jdgenometracks-0.2.1.tar.gz",
    "platform": null,
    "description": "# **jdgenometracks**\n\n## Overview\n\n**jdgenometracks** is a Python package designed to simplify the visualization of genomic data using **Plotly** and **Matplotlib**. The package supports visualizing different track types such as **BED**, **BEDGRAPH**, and **axis** tracks, making it ideal for managing and plotting large genomic datasets with customizable visual styles.\n\nAt the core of the package is the **TrackFactory**, which allows users to easily create and manage genomic tracks, enabling the use of both Plotly and Matplotlib with the same set of track definitions.\n\n## Key Features\n\n- **TrackFactory** for easy creation of tracks (e.g., BED, BEDGRAPH, axis, and spacer tracks).\n- Supports **Plotly** and **Matplotlib** visualization.\n- Customizable plotting options (e.g., colors, markers, lines).\n- Easily handle large genomic datasets and visualize them in multiple columns or rows.\n\n## Installation\n\n```bash\npip install jdgenometracks\n```\n\n## Getting Started\n\n### Example: Creating and Plotting Tracks with Plotly\n\n```python\nimport jdgenometracks as jdg\n\n# Define a set of tracks to visualize\ntracks = [\n    jdg.TrackFactory.create_track(\n        file_path=\"example_data/track1.bedgraph\",\n        track_name=\"Track 1\",\n        track_type=\"bedgraph\",\n        plot_type=\"points\",\n        plotly_options={\n            \"marker_color\": \"blue\",\n            \"marker_size\": 4\n        }\n    ),\n    jdg.TrackFactory.create_track(\n        file_path=\"example_data/track2.bed\",\n        track_name=\"Track 2\",\n        track_type=\"bed\",\n        plotly_options={\n            \"fillcolor\": \"red\",\n            \"line_color\": \"black\"\n        }\n    ),\n    jdg.TrackFactory.create_track(\n        track_name=\"Bottom Axis\",\n        track_type=\"axis\",\n        axis_type=\"verbose\"\n    )\n]\n\n# Now, pass these tracks to a Plotly plotting utility (example):\nplotter = jdg.PlotlyPlotter(tracks, total_height=800)\nfig = plotter.plot_all_tracks(column_titles=[\"Sample Data\"])\nfig.show()\n```\n\n### Example: Creating and Plotting Tracks with Matplotlib\n\n```python\nimport jdgenometracks as jdg\n\n# Define a set of tracks for Matplotlib\ntracks = [\n    jdg.TrackFactory.create_track(\n        file_path=\"example_data/track1.bedgraph\",\n        track_name=\"Track 1\",\n        track_type=\"bedgraph\",\n        plot_type=\"lines\",\n        mpl_plot_options={\n            \"color\": \"blue\",\n            \"linewidth\": 2\n        }\n    ),\n    jdg.TrackFactory.create_track(\n        file_path=\"example_data/track2.bed\",\n        track_name=\"Track 2\",\n        track_type=\"bed\",\n        mpl_rect_options={\n            \"color\": \"red\",\n            \"linewidth\": 2\n        },\n        mpl_text_options={\n            \"va\": \"center\"\n        },\n        mpl_text_alignment=\"right\"\n    ),\n    jdg.TrackFactory.create_track(\n        track_name=\"Bottom Axis\",\n        track_type=\"axis\",\n        axis_type=\"verbose\"\n    )\n]\n\n# Use a Matplotlib plotter\nplotter = jdg.MPLPlotter(tracks, total_height=8)\nfig, axes = plotter.plot_all_tracks(plot_title=\"Genomic Data\")\nplt.show()\n```\n\n### Example: Displaying Two Columns of Tracks with Plotly\n\n```python\nimport jdgenometracks as jdg\nimport numpy as np\n\n# Define two sets of tracks to display in two columns\ntracks = [\n    # First Column (Column 1)\n    jdg.TrackFactory.create_track(\n        file_path=\"example_data/track1_column1.bedgraph\",\n        track_name=\"Track 1 - Column 1\",\n        track_type=\"bedgraph\",\n        plot_type=\"points\",\n        plotly_options={\n            \"marker_color\": \"blue\",\n            \"marker_size\": 4\n        }\n    ),\n    jdg.TrackFactory.create_track(\n        file_path=\"example_data/track2_column1.bed\",\n        track_name=\"Track 2 - Column 1\",\n        track_type=\"bed\",\n        plotly_options={\n            \"fillcolor\": \"red\",\n            \"line_color\": \"black\"\n        }\n    ),\n    jdg.TrackFactory.create_track(\n        track_name=\"Bottom Axis - Column 1\",\n        track_type=\"axis\",\n        axis_type=\"verbose\"\n    ),\n\n    # Second Column (Column 2)\n    jdg.TrackFactory.create_track(\n        file_path=\"example_data/track1_column2.bedgraph\",\n        track_name=\"Track 1 - Column 2\",\n        track_type=\"bedgraph\",\n        plot_type=\"lines\",\n        plotly_options={\n            \"line_color\": \"green\",\n            \"line_width\": 2\n        }\n    ),\n    jdg.TrackFactory.create_track(\n        file_path=\"example_data/track2_column2.bed\",\n        track_name=\"Track 2 - Column 2\",\n        track_type=\"bed\",\n        plotly_options={\n            \"fillcolor\": \"purple\",\n            \"line_color\": \"black\"\n        }\n    ),\n    jdg.TrackFactory.create_track(\n        track_name=\"Bottom Axis - Column 2\",\n        track_type=\"axis\",\n        axis_type=\"verbose\"\n    )\n]\n\n# Reshape the tracks to 2 columns (first 3 tracks in column 1, next 3 in column 2)\ntracks = np.array(tracks).reshape(-1, 2)\n\n# Plot using PlotlyPlotter\nplotter = jdg.PlotlyPlotter(tracks, total_height=800)\nfig = plotter.plot_all_tracks(\n    column_titles=[\"Column 1\", \"Column 2\"],  # Titles for each column\n    height_props=[1, 1, 0.1],  # Proportions for each row (tracks and axis)\n    width_props=[1, 1]  # Equal width for both columns\n)\n\n# Display the figure\nfig.show()\n```\n\n## TrackFactory Usage\n\nThe **TrackFactory** allows you to create different types of tracks. Here are some examples of how to use the factory to create tracks:\n\n### BEDGRAPH Track\n\n```python\njdg.TrackFactory.create_track(\n    file_path=\"path/to/file.bedgraph\",\n    track_name=\"Example BEDGRAPH\",\n    track_type=\"bedgraph\",\n    plot_type=\"lines\",\n    plotly_options={\n        \"line_color\": \"green\",\n        \"line_width\": 2\n    }\n)\n```\n\n### BED Track\n\n```python\njdg.TrackFactory.create_track(\n    file_path=\"path/to/file.bed\",\n    track_name=\"Example BED\",\n    track_type=\"bed\",\n    plotly_options={\n        \"fillcolor\": \"purple\",\n        \"line_width\": 2\n    }\n)\n```\n\n### Axis Track\n\n```python\njdg.TrackFactory.create_track(\n    track_name=\"X-Axis\",\n    track_type=\"axis\",\n    axis_type=\"verbose\"\n)\n```\n\n## Customizing Plots\n\nEach track can be customized using **Plotly** keyword arguments or **Matplotlib** keyword arguments. Example options include:\n\n- **Colors**: Set line and marker colors.\n- **Line Styles**: Adjust line widths and types.\n- **Markers**: Control marker styles (e.g., size, symbol).\n- **Axes**: Customize axis labels and ticks.\n\n## Advanced Usage\n\nFor more advanced use cases, you can extend the package to support new track types or customize existing ones by modifying the `TrackFactory` to handle additional parameters or features.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Python package for plotting genomic data.",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/justin-delano/jdgenometracks"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff29a0ba319da56eb7b3e8979945588a6ea2cf71780badb7a3527fb33df4ae91",
                "md5": "be0d20f4f912165ecb497fbe4f4ffb9d",
                "sha256": "46ef546ebc67aa8209041b7441046c19fc921bc69c0d28fad848a4c175649ccc"
            },
            "downloads": -1,
            "filename": "jdgenometracks-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "be0d20f4f912165ecb497fbe4f4ffb9d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 22524,
            "upload_time": "2024-09-11T17:43:28",
            "upload_time_iso_8601": "2024-09-11T17:43:28.757850Z",
            "url": "https://files.pythonhosted.org/packages/ff/29/a0ba319da56eb7b3e8979945588a6ea2cf71780badb7a3527fb33df4ae91/jdgenometracks-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c9e8f75f4e39b391262e855101ff4b5821274e502813b0808fd158f0136ccbe",
                "md5": "196b6eeb0fc1ce644a3c1e26c3def0c7",
                "sha256": "9f710d7b908e08bea4d6bc9406dde4a5f3cc7539d5ca32793015e7e8bb3a84e4"
            },
            "downloads": -1,
            "filename": "jdgenometracks-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "196b6eeb0fc1ce644a3c1e26c3def0c7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 18278,
            "upload_time": "2024-09-11T17:43:29",
            "upload_time_iso_8601": "2024-09-11T17:43:29.717627Z",
            "url": "https://files.pythonhosted.org/packages/6c/9e/8f75f4e39b391262e855101ff4b5821274e502813b0808fd158f0136ccbe/jdgenometracks-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-11 17:43:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "justin-delano",
    "github_project": "jdgenometracks",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "jdgenometracks"
}
        
Elapsed time: 0.57279s