GithubHelp home page GithubHelp logo

ckarfusehr / gelpy Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 5.0 21.85 MB

A modern python package for semi-automated gel electrophoresis analysis (Agarose, PAGE, ...)

License: GNU General Public License v3.0

Python 100.00%
agarose-gel electrophoresis peak-fitting python

gelpy's Introduction

Welcome to the gelpy project

DOI

If you are looking for a Python package for simplified, reproducible, and easily shareable gel electrophoresis analysis, you are in the right place. If you are also keen on contributing to a Python project, then hey, you are also in the right place!

Please note that this package is under development and currently in its alpha phase. I would like to invite you to try gelpy, break it, and contribute to it. Valuable contributions include raising issues on the GitHub issues page or, if you want to do some coding, fixing the issue and submitting a merge request to this repository. In any case, I believe that even in its early state, gelpy can make your life working with electrophoresis gels more pleasant and reproducible.

What can gelpy do?

As of now, this package includes functions to:

  • Visualize gels with automatically adjusted contrasts (linear and non-linear)
  • Label the lanes
  • Remove the image background
  • Extract and plot lane profiles
  • Fit the peaks (bands) of lane profiles
  • Save all generated images
  • Save the gel object, including all the plots, lane profiles, and fits, as a Python object. You can then send this object as one file to your collaborator, who can load it back into Python and continue where you left off.

Another benefit of using this package over, for example, Fiji for data extraction is that all lane profiles, fitting parameters, and the original image are directly available in Python and do not have to be saved and imported again for further custom analysis

Installation

pip

conda create -n <your_environment_name> python
conda activate <your_environment_name>
pip installl gelpy

How to use gelpy

I recommend checking out the example Jupyter notebook in the "Example" folder. I hope to add proper documentation soon. Also, please note that the docstring was generated with GPT and may potentially contain errors in its current state.

How to contribute by coding

Does this pique your interest in contributing? Perhaps even implementing new features? I have an unstructured list below where I collect ideas for tasks to be done or features to be implemented.

Loose notes

  • translate docstrings to reStructuredText, such that Sphinx can read it.
  • Compose docs with Sphinx and make it available on read the docs.
  • Allow direct extraction of non-normalized, raw intensity values.
  • Extract remaining magic numbers and magic strings to the top of each class file (using GPT).
  • Write (more) unit tests.
  • Add optional interactive IPython widgets to set up the gel.
  • Add some autodetection functions that provide reasonable guesses for the parameters in the gel.setup_gel() function.
    • Implement a function to autodetect the lane positions based on summing them up along the y-axis, followed by a peak detection scheme. Perhaps add another function that calculates the optimal lane width used for all lanes?
  • Implement another peak-finding algorithm based on inflection point detection of a spline-fitted function.
  • Add utility functions to crop and rotate images so that people can directly use their recorded images.
  • Include a logfile or YAML file that saves all the used parameters for quantitative data extraction in a separate text file. This simplifies reproducibility.

New class for quantitative band analysis

  • Set up a new class that can be used for quantitative gel analysis (e.g., in ng per band). The class should accept the ladder used, the applied ladder concentration, and volume. It should calculate a calibration curve based on this information and use it to convert the intensities of other bands into sample mass.

gelpy's People

Contributors

ckarfusehr avatar goblin-0-0-7 avatar

Stargazers

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

Watchers

 avatar  avatar

gelpy's Issues

doesn't initialize with rgb .tif file

It worked once I fixed my tif and made it grayscale with imageJ. Just leaving here so people silly like me can figure it out :)

Hi! I'm not very experienced with this package using stuff so sorry if this is just a me thing.
I'm trying to use the example notebook as a framework to start my analysis but setup_gel method doesn't work with my .tif

I think its because my tifs are in RBG colorspace while both the examples are in Gray colorspace (according to the "information" provided in finder). I'm not sure if I should change it in Fiji or something or if there's a way to make gelpy accept the rbg color information.

Here's the error trace if that's helpful:

ValueError Traceback (most recent call last)
Cell In[14], line 13
6 #gel.setup_gel()
7 #gel.show_adjusted_images(save_adjusted_gels="test123.jpg")
8
9 # gel.setup_gel(x_label_pos=(150, 4480, 20),
10 # remove_bg=True) #, line_profile_width=150)
12 labels = ["scaffold", "2 MgCl₂, 500 NaCl","4 MgCl₂, 500 NaCl","6 MgCl₂, 500 NaCl","8 MgCl₂, 500 NaCl","10 MgCl₂, 500 NaCl","150 NaCl","300 NaCl","400 NaCl","500 NaCl","600 NaCl", "700 NaCl","6 MgCl₂","10 MgCl₂","6 MgCl₂, 150 NaCl,1/2 scaf","10 MgCl₂, 150 NaCl,1/2 scaf","6 MgCl₂, 300 NaCl,1/2 scaf","10 MgCl₂, 300 NaCl,1/2 scaf","6 MgCl₂, 500 NaCl,1/2 scaf"," 10 MgCl₂, 500 NaCl,1/2 scaf"]
---> 13 gel.setup_gel(labels=labels, x_label_pos=(150, 4485, 20),
14 label_rotation=90,
15 line_profile_width=180,
16 remove_bg=True,
17 img_height_factor=1) # increase if labels and titles are overlapping
18 gel.show_adjusted_images()

File /opt/anaconda3/lib/python3.8/site-packages/gelpy/package_api.py:71, in Gel.setup_gel(self, labels, x_label_pos, gamma, gain, intensity_range, img_height_factor, label_rotation, save, show_type, line_profile_width, remove_bg, bg_model, bg_model_input)
40 def setup_gel(self, labels=None, x_label_pos=None, gamma=DEFAULT_GAMMA, gain=DEFAULT_GAIN,
41 intensity_range=DEFAULT_INTENSITY_RANGE, img_height_factor=DEFAULT_IMG_HEIGHT_FACTOR,
42 label_rotation=DEFAULT_LABEL_ROTATION, save=False,
43 show_type=DEFAULT_SHOW_TYPE, line_profile_width=None,
44 remove_bg=False, bg_model=MODEL_2D_PLANE_FIT_NAME, bg_model_input=None):
45 """
46 Initializes the gel instance by loading the image, adjusting its properties and optionally
47 removing its background.
(...)
68 ValueError: If an invalid fit type is provided.
69 """
---> 71 self.init_image(labels, x_label_pos, gamma, gain, intensity_range, img_height_factor, label_rotation)
73 self.plot_and_adjust_gels(show_type)
74 self.setup_line_profile(line_profile_width)

File /opt/anaconda3/lib/python3.8/site-packages/gelpy/package_api.py:112, in Gel.init_image(self, labels, x_label_pos, gamma, gain, intensity_range, img_height_factor, label_rotation)
99 def init_image(self, labels, x_label_pos, gamma, gain, intensity_range, img_height_factor, label_rotation):
100 """
101 Initializes the gel image with the provided parameters.
102
(...)
110 label_rotation (int): The rotation angle of the labels.
111 """
--> 112 self.Image = Image(self.image, self.file_name_without_ext, labels, x_label_pos, label_rotation,
113 img_height_factor=img_height_factor, gamma=gamma, gain=gain, intensity_range=intensity_range)
114 self.labels = self.Image.labels
115 self.x_label_pos = x_label_pos

File /opt/anaconda3/lib/python3.8/site-packages/gelpy/image_handling.py:33, in Image.init(self, image, file_name_withou_extension, labels, x_label_pos, label_rotation, img_height_factor, gamma, gain, intensity_range)
31 # Attributes
32 self.gel_image = image
---> 33 self.image_height, self.image_width = self.gel_image.shape
34 self.file_name_without_extension = file_name_withou_extension
35 self.labels = labels

ValueError: too many values to unpack (expected 2)

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.