Skip to main content

Analysis tools for SLEAP-based plant root phenotyping.

Project description

sleap-roots

CI codecov Release PyPI

Analysis tools for SLEAP-based plant root phenotyping.

Installation

pip install sleap-roots

If you are using conda (recommended):

conda create -n sleap-roots python=3.11
conda activate sleap-roots
pip install sleap-roots

Usage

Detailed trait documentation per pipeline is available here: sleap-roots HackMD

DicotPipeline

1. Computing traits for a single plant:

import sleap_roots as sr

plant = sr.Series.load(
    "tests/data/canola_7do/919QDUH.h5",
    # Specify the names of the primary and lateral roots for trait calculation
    primary_name="primary",
    lateral_name="lateral"
)
pipeline = sr.DicotPipeline()
traits = pipeline.compute_plant_traits(plant, write_csv=True)

2. Computing traits for a batch of plants:

import sleap_roots as sr

plant_paths = sr.find_all_series("tests/data/soy_6do")
plants = [
    sr.Series.load(
        plant_path,
        # Specify the names of the primary and lateral roots for trait calculation
        primary_name="primary",
        lateral_name="lateral",
    ) for plant_path in plant_paths]

pipeline = sr.DicotPipeline()
all_traits = pipeline.compute_batch_traits(plants, write_csv=True)

3. Computing individual traits:

import sleap_roots as sr
import numpy as np
import numpy as np
# Import utility for combining primary and lateral root points
from sleap_roots.points import get_all_pts_array

plant = sr.Series.load(
    "tests/data/canola_7do/919QDUH.h5",
    primary_name="primary",
    lateral_name="lateral"
)

frame_index = 0
primary_pts = plant.get_primary_points(frame_index)
lateral_pts = plant.get_lateral_points(frame_index)
pts = get_all_pts_array(primary_pts, lateral_pts)
convex_hull = sr.convhull.get_convhull(pts)

YoungerMonocotPipeline

1. Computing traits for a single plant:

import sleap_roots as sr

plant = sr.Series.load(
    "tests/data/rice_3do/0K9E8BI.h5",
    primary_name="primary",
    lateral_name="crown"
)
pipeline = sr.YoungerMonocotPipeline()
traits = pipeline.compute_plant_traits(plant, write_csv=True)

2. Computing traits for a batch of plants:

import sleap_roots as sr

plant_paths = sr.find_all_series("tests/data/rice_3do")
plants = [
    sr.Series.load(
        plant_path,
        primary_name="primary",
        lateral_name="crown"
    ) for plant_path in plant_paths]

pipeline = sr.YoungerMonocotPipeline()
all_traits = pipeline.compute_batch_traits(plants, write_csv=True)

3. Computing individual traits:

import sleap_roots as sr
import numpy as np
from sleap_roots.points import get_all_pts_array

plant = sr.Series.load(
    "tests/data/rice_3do/0K9E8BI.h5",
    primary_name="primary",
    lateral_name="crown"
)

frame_index = 0
primary_pts = plant.get_primary_points(frame_index)
lateral_pts = plant.get_lateral_points(frame_index)
pts = get_all_pts_array(primary_pts, lateral_pts)
convex_hull = sr.convhull.get_convhull(pts)

Tutorials

Jupyter notebooks are located in this repo at sleap-roots/notebooks.

To use them, activate your conda environment which includes JupyterLab (recommended):

conda activate sleap-roots

Clone this repository if you haven't already:

git clone https://github.com/talmolab/sleap-roots.git && cd sleap-roots

Then you can change directories to the location of the notebooks, and open Jupyter Lab:

cd notebooks
jupyter lab

Go through the commands in the notebooks to learn about each pipeline. You can use the test data located at tests/data or copy the notebooks elsewhere for use with your own data!

Development

For development, first clone the repository:

git clone https://github.com/talmolab/sleap-roots && cd sleap-roots

Then, to create a new conda environment and install the package in editable mode:

conda env create -f environment.yml

This will create a conda environment called sleap-roots.

If you have an existing conda environment (such as where you installed SLEAP), you can just install in editable mode directly. First, activate your environment and then:

pip install -e ".[dev]"

Note: The [dev] makes sure that the development-only dependencies are also installed.

To start fresh, just delete the environment:

conda env remove -n sleap-roots

To run tests, first activate the environment:

conda activate sleap-roots

Then run pytest with:

pytest tests

Acknowledgments

This repository was created by the Talmo Lab and Busch Lab at the Salk Institute for Biological Studies as part of the Harnessing Plants Initiative.

Contributors

  • Elizabeth Berrigan
  • Lin Wang
  • Talmo Pereira

Citation

E.M. Berrigan, L. Wang, H. Carrillo, K. Echegoyen, M. Kappes, J. Torres, A. Ai-Perreira, E. McCoy, E. Shane, C.D. Copeland, L. Ragel, C. Georgousakis, S. Lee, D. Reynolds, A. Talgo, J. Gonzalez, L. Zhang, A.B. Rajurkar, M. Ruiz, E. Daniels, L. Maree, S. Pariyar, W. Busch, T.D. Pereira.
"Fast and Efficient Root Phenotyping via Pose Estimation", Plant Phenomics 0: DOI:10.34133/plantphenomics.0175.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

sleap_roots-0.1.3-py3-none-any.whl (45.0 kB view details)

Uploaded Python 3

File details

Details for the file sleap_roots-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: sleap_roots-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 45.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for sleap_roots-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e3173b1cee13674f43d3262ce36b26fbafa7f0b2bad78de3e06eb07a418da5af
MD5 6816da0754c66bd3bcebbd828bb83d5b
BLAKE2b-256 405bcefb8bb32b45396114cbc79f0d64832bf5b076bc31e2c0955f0a925ea8a4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page