Giter Site home page Giter Site logo

ppreshant / qpcr-analysis Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 3.0 5.15 MB

Takes excel file output from qPCR (Quantstudio3, ABI) and sample labels. Optionally analyzes standard curves and plots CT, Tms and absolute copies

License: GNU General Public License v3.0

R 4.77% Python 0.12% HTML 95.11%
qpcr data-analysis

qpcr-analysis's Introduction

qPCR-analysis from Cq values

Takes excel file output from qPCR machine, sample names layout and optional standard curve parameters. Plots Cq data, absolute concentrations and Tms in a neat format, ~ almost ready for publication.

  • Code works with .xlsx file output by Applied Biosystems Quantstudio-3)
  • If you need to analyze data from other instruments and if the current code fails, export to RDML format and use the script linregpcr_processing.R

standard curve : Include Stdxx (xx = numbering) in the excel file name to process data and make a standard curve using data within the file

If you're wondering that you can do all this with your expert excel skills, here's my rationale to convince you: Coding this trivial analysis and plotting is very useful because I run tons of qPCR and I want all the plots to have the same formatting for easy comparision of data between runs without clicking around for every analysis. I wouldn't want to plot all these on excel! The script is especially handy when I run some experiment in a hurry for a meeting and I can get something to show in 2 mins by running the script ๐Ÿ˜‚

Instructions to run the tool

  1. Clone the respository using git onto your computer. This brings in the code files and also mimics the folder structure (check if all the necessary folders are present)
  2. Open the scripts in R by clicking on the qPCR analysis.Rproj file. _This ensures that R's current working directory is at the base of this project.
    • If you haven't you need to install R, Rstudio, git; and install the packages listed with the library commands in 0-general_functions_main.R script using install.packages('..')_
  3. Set metadata sheets: Default option is to add your plate layout in the excel files/Plate layout.xlsx file. Make sure the template_source variable is set to 'excel' in 0.5-user-inputs.R file.
    • If you would prefer a cloud option, then make a googlesheet with sheets named qPCR plate layouts and qPCR Std curves following the template from my sheet
    • Copy the url of your googlesheet and replace the one in sheeturls = list(plate_layouts_PK = .. in the script 0-general_functions_main.R

Day to day running for new datasets

  1. Enter your sample name details into the Plate layouts sheet in a format of your choice (excel / googlesheets)
  2. Open 0.5-user-inputs.R script. Change only the flnm variable (for simple runs). and other options by following the comments in the file
  3. You can try running the template file q50_S080_RAM 80a_mjd61 repression_new barcode within the excel files/ folder. Metadata for this is provided in the Plate layouts.xlsx sheet in the same folder, and this should be read by changing the template_source <- to 'excel' in the user settings file 0.5-user_inputs.R. _Side note: I read this from a google sheet that enables me to setup qPCRs by looking at this sheet on my phone :). Here is my google sheet with the metadata.
  4. Open analysis.R script and source it to analyze the data.

Sample naming scheme Sample names are written in a google sheet (contact me for access to see the template) in this particular format targetname_samplecategory_templatename with an optional _biologicalreplicatenumber in the end

  • targetname = name of the amplicon, ex: 16S, U64, spliced. _When plotting, each target is shown in a separate facet using facet_grid()
  • samplecategory could stand for test, positive, negative (controls) or NoRT control etc. This will be used to colour data in the plot
  • templatename = name of the DNA or RNA sample loaded as the template. this appears on the x/y axes of the plot
  • biologicalreplicatenumber = 1,2,3 .. If not provided, the code makes it in a rowwise order. This is useful to plot all replicates in the same template location and plot averages of the replicates Examples: 16S_negative_MG1655 or 16S_Maximal_AOS109 image

The output image looks like this

  • targetname becomes facets or panels (boxes on the top);
  • samplecategory as colour (named as Sample_name)
  • templatename on the x axis (named assay_variable in the code) and

Code organization

  1. main branch holds the latest version of the code for general purpose plotting for any qPCR output file with sample names in the above way
  2. For customized plots for individual experiments, you can process the data with the regular script and then code custom .R scripts to rename data and re-plot the data in your own way. Scripts of this kind that I used for my experiments are in the adhoc_scripts/ folder.
  3. The main

qPCR analysis using LinRegPCR

Linregpcr tool analyzes raw qPCR curves and calculates the ~initial fluorescence which can be converted into initial concentration using calibration standards (6 replicates of the same concentration known standard). I have made a wrapper to run their python version of LinRegPCR through R, but the portability and documentation is in progress.

If you want to try it out, the script is called linregpcr_processing.R

How does LinRegPCR work?

image

Summary: The linregPCR method is more robust and open source compared to proprietary methods used by vendor software. This works with curves that have a reasonable baseline and plateau region with good plateau intensity above baseline. This could be problematic for probe based data, or samples with very high (ex: 16S) or very low quantifications, so iterate and decide for yourself if this is right for you.

  • LinRegPCR outputs both efficiency and Cq values which are used for quantification. Absolute quantification can be done using calibration with a single concentration of known concentration sample x 6 replicates

Source: Untergasser, Andreas, et al. "Web-based LinRegPCR: Application for the visualization and analysis of (RT)-qPCR amplification and melting data." BMC bioinformatics 22.1 (2021): 1-18.).

Copyleft : GPL-3.0-or-later license

wrappers for automated processing and plotting of bacterial flow cytometry data 
Copyright (C) 2023  Prashant Kalvapalle

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

qpcr-analysis's People

Contributors

ppreshant avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

qpcr-analysis's Issues

Fix recent error with plotly : Prevents any plots -> `.html` from being made

Error when analysis.R with q54_S079-RNA2_Travis-1-5_RAM.xls file. The empty string after '40-CT' is the issue, not the plot title!

processing file: make_html_plots.rmd
  |....      |  38% [cq_plt]      
Quitting from lines 32-42 [cq_plt] (make_html_plots.rmd)
Error in `train()`:
! unused argument (list("q54_S079-RNA2_Travis-1-5_RAM", "40 - Cq", "40 - CT", "", "Sample_category"))
Backtrace:
 1. plotly::ggplotly(horz.cq)
 2. plotly:::ggplotly.ggplot(horz.cq)
 3. plotly::gg2list(...)
 4. plotly:::get_gdefs_ggproto(npscales$scales, theme, plot, layers)
 5. guides$train(scales, theme$legend.direction, plot$labels)
Warning messages:
1: In class(fl$Results$CT) <- "numeric" : NAs introduced by coercion
2: Removed 11 rows containing
missing values or values outside
the scale range (`geom_point()`). 
3: Removed 11 rows containing
missing values or values outside
the scale range (`geom_point()`). 
4: Removed 11 rows containing
missing values or values outside
the scale range (`geom_point()`). 
5: Removed 11 rows containing
missing values or values outside
the scale range (`geom_point()`). 
6: Removed 11 rows containing
missing values or values outside
the scale range (`geom_point()`). 
7: Removed 11 rows containing
missing values or values outside
the scale range (`geom_point()`). 
8: Removed 11 rows containing
non-finite outside the scale
range (`stat_boxplot()`). 
9: Removed 11 rows containing
missing values or values outside
the scale range (`geom_point()`).

default figure width in Rmd?

Figure with multiple facets has the x labels overlapping if fig.width and fig.height is not set in the Rmd parameters. Is this due to default width provided by ggplot or by rmd?

If these don't need to be hard coded it will be good

Reduce the number of very similar `assay_var..` columns

There are 4 columns all of which serve the same purpose. Please clean them up into a single renamed column as mentioned in #1

> select(combined_data, contains('assay')) %>% colnames
[1] "assay_var.horz_label" "assay_variable"       "assay_var.identifier" "assay_var.label" ```

Implement a Tm range where Cq plot will lighten points with Tm1 outside range (primer dimers etc.)

Make a new column with this info :

  1. Need to know negative controls (from a user input, ex: 89, NTC, NoRT) and mark them as negative
  2. Need to recognize which is the positive/test case for each primerpair (facet) -- by user input for positives, and by exclusion for test (everything else is test case)
  3. Calculate a range of +/_ 2 oC (seems pretty adhoc.. is there a better way? read literature) around the Tm1 of the positive control (if exists) or test (after group_by each primer pair)
  4. (optional) Make a new column for Tm outside the range -- good for data output?
  5. Pass alpha as within the range or outside the range with 1 and 0.4

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.