├── vignettes ├── .gitignore ├── lib.bib ├── qPCRtools.Rmd └── chinese-gb7714-2005-numeric.csl ├── NAMESPACE ├── LICENSE ├── inst ├── examples │ ├── crtv.template.txt │ ├── crtv.data.txt │ ├── cat.expre.curve.sdc.csv │ ├── cal.expre.curve.sdc.csv │ ├── calsc.cq.txt │ ├── calsc.info.txt │ ├── cal.exp.curve.design.csv │ └── cal.exp.curve.cq.csv ├── golem-config.yml └── calsc.info.txt ├── .Rbuildignore ├── .gitignore ├── CRAN └── qPCRtools │ ├── LICENSE │ ├── inst │ ├── examples │ │ ├── crtv.template.txt │ │ ├── crtv.data.txt │ │ ├── cal.expre.curve.sdc.txt │ │ ├── cat.expre.curve.sdc.csv │ │ ├── cal.expre.curve.sdc.csv │ │ ├── ddct.cq.txt │ │ ├── cal.exp.curve.cq.txt │ │ ├── cal.expre.rqpcr.cq.txt │ │ ├── dct.cq.txt │ │ ├── calsc.cq.txt │ │ ├── calsc.info.txt │ │ ├── dct.design.txt │ │ ├── cal.exp.curve.design.csv │ │ ├── cal.exp.curve.design.txt │ │ ├── ddct.design.txt │ │ ├── cal.expre.rqpcr.design.txt │ │ └── cal.exp.curve.cq.csv │ ├── golem-config.yml │ └── calsc.info.txt │ ├── DESCRIPTION │ ├── NAMESPACE │ ├── man │ ├── CalExp2dCt.Rd │ ├── CalRTable.Rd │ ├── CalCurve.Rd │ ├── CalExpRqPCR.Rd │ ├── CalExp2ddCt.Rd │ └── CalExpCurve.Rd │ └── R │ ├── CalRTable.R │ ├── CalExp2dCt.R │ ├── CalCurve.R │ ├── CalExpCurve.R │ ├── CalExp2ddCt.R │ └── CalExpRqPCR.R ├── qPCRtools_1.0.1.tar.gz ├── man └── hello.Rd ├── qPCRtools.Rproj ├── DESCRIPTION ├── LICENSE.md ├── R ├── CalRTable.R ├── CalExp2dCt.R ├── CalCurve.R ├── CalExpCurve.R ├── CalExp2ddCt.R └── CalExpRqPCR.R ├── development.record.R └── README.md /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | exportPattern("^[[:alpha:]]+") 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2022 2 | COPYRIGHT HOLDER: Xiang LI 3 | -------------------------------------------------------------------------------- /inst/examples/crtv.template.txt: -------------------------------------------------------------------------------- 1 | mix gDNARemover all 2 | 4 1 20 -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^LICENSE\.md$ 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2022 2 | COPYRIGHT HOLDER: Xiang LI 3 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/crtv.template.txt: -------------------------------------------------------------------------------- 1 | mix gDNARemover all 2 | 4 1 20 -------------------------------------------------------------------------------- /qPCRtools_1.0.1.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lixiang117423/qPCRtools/HEAD/qPCRtools_1.0.1.tar.gz -------------------------------------------------------------------------------- /inst/examples/crtv.data.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lixiang117423/qPCRtools/HEAD/inst/examples/crtv.data.txt -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/crtv.data.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lixiang117423/qPCRtools/HEAD/CRAN/qPCRtools/inst/examples/crtv.data.txt -------------------------------------------------------------------------------- /man/hello.Rd: -------------------------------------------------------------------------------- 1 | \name{hello} 2 | \alias{hello} 3 | \title{Hello, World!} 4 | \usage{ 5 | hello() 6 | } 7 | \description{ 8 | Prints 'Hello, world!'. 9 | } 10 | \examples{ 11 | hello() 12 | } 13 | -------------------------------------------------------------------------------- /inst/golem-config.yml: -------------------------------------------------------------------------------- 1 | default: 2 | golem_name: qPCRtools 3 | golem_version: 0.0.0.9000 4 | app_prod: no 5 | production: 6 | app_prod: yes 7 | dev: 8 | golem_wd: D:/JianGuoYun/Program/qPCRtools 9 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/golem-config.yml: -------------------------------------------------------------------------------- 1 | default: 2 | golem_name: qPCRtools 3 | golem_version: 0.0.0.9000 4 | app_prod: no 5 | production: 6 | app_prod: yes 7 | dev: 8 | golem_wd: D:/JianGuoYun/Program/qPCRtools 9 | -------------------------------------------------------------------------------- /qPCRtools.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: qPCRtools 2 | Authors@R: person('Xiang', 'LI', email = 'lixiang117423@gmail.com', role = c('cre', 'aut')) 3 | Version: 1.0.1 4 | Title: Tools for qPCR 5 | Description: PKG_DESC. 6 | URL: https://github.com/lixiang117423/qPCRtools 7 | BugReports: https://github.com/lixiang117423/qPCRtools/issues 8 | License: MIT + file LICENSE 9 | Imports: 10 | broom, 11 | dplyr, 12 | ggplot2, 13 | ggpmisc, 14 | ggthemes, 15 | kableExtra, 16 | magrittr, 17 | multcomp, 18 | rstatix, 19 | stats, 20 | tibble, 21 | tidyr 22 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: qPCRtools 2 | Authors@R: person('Xiang', 'LI', email = 'lixiang117423@gmail.com', role = c('cre', 'aut')) 3 | Version: 1.0.1 4 | Title: Tools for qPCR 5 | Description: PKG_DESC. 6 | URL: https://github.com/lixiang117423/qPCRtools 7 | BugReports: https://github.com/lixiang117423/qPCRtools/issues 8 | License: MIT + file LICENSE 9 | Imports: 10 | broom, 11 | dplyr, 12 | ggplot2, 13 | ggpmisc, 14 | ggthemes, 15 | kableExtra, 16 | magrittr, 17 | multcomp, 18 | rstatix, 19 | stats, 20 | tibble, 21 | tidyr 22 | RoxygenNote: 7.2.3 23 | -------------------------------------------------------------------------------- /vignettes/lib.bib: -------------------------------------------------------------------------------- 1 | @article{livak2001analysis, 2 | title={Analysis of relative gene expression data using real-time quantitative PCR and the 2- $\Delta$$\Delta$CT method}, 3 | author={Livak, Kenneth J and Schmittgen, Thomas D}, 4 | journal={methods}, 5 | volume={25}, 6 | number={4}, 7 | pages={402--408}, 8 | year={2001}, 9 | publisher={Elsevier} 10 | } 11 | 12 | @article{rancurel2019satqpcr, 13 | title={SATQPCR: Website for statistical analysis of real-time quantitative PCR data}, 14 | author={Rancurel, Corinne and Van Tran, Trang and Elie, C{\'e}line and Hilliou, Fr{\'e}d{\'e}rique}, 15 | journal={Molecular and cellular probes}, 16 | volume={46}, 17 | pages={101418}, 18 | year={2019}, 19 | publisher={Elsevier} 20 | } 21 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(CalCurve) 4 | export(CalExp2dCt) 5 | export(CalExp2ddCt) 6 | export(CalExpCurve) 7 | export(CalExpRqPCR) 8 | export(CalRTable) 9 | importFrom(broom,glance) 10 | importFrom(dplyr,filter) 11 | importFrom(dplyr,group_by) 12 | importFrom(dplyr,left_join) 13 | importFrom(dplyr,mutate) 14 | importFrom(dplyr,rename) 15 | importFrom(dplyr,select) 16 | importFrom(dplyr,ungroup) 17 | importFrom(ggplot2,aes) 18 | importFrom(ggplot2,geom_point) 19 | importFrom(ggplot2,geom_smooth) 20 | importFrom(ggplot2,ggplot) 21 | importFrom(ggplot2,labs) 22 | importFrom(ggplot2,theme_bw) 23 | importFrom(ggpmisc,stat_poly_eq) 24 | importFrom(kableExtra,kable) 25 | importFrom(kableExtra,kable_styling) 26 | importFrom(magrittr,"%>%") 27 | importFrom(stats,lm) 28 | -------------------------------------------------------------------------------- /inst/examples/cat.expre.curve.sdc.csv: -------------------------------------------------------------------------------- 1 | Gene,Formula,Slope,Intercept,R2,P.value,max,min,Date 2 | OsGns1,RC = -0.97xCq + 31.95,-0.97,31.95,0.9992,0,30.84,20.53,2021-11-11 3 | OsUBQ,RC = -0.9xCq + 32.04,-0.9,32.04,0.9992,0,33.24,22.25,2021-11-11 4 | OsWRKY71,RC = -0.98xCq + 30.77,-0.98,30.77,0.9999,0,29.48,19.12,2021-11-11 5 | OsPOX8,RC = -0.91xCq + 34.48,-0.91,34.48,0.999,0,36.08,24.8,2021-11-11 6 | OsWAK91,RC = -0.91xCq + 36.77,-0.91,36.77,0.9954,0,34.75,27.12,2021-11-11 7 | OsPR10,RC = -0.99xCq + 41.22,-0.99,41.22,0.9695,0,36.3,29.39,2021-11-11 8 | OsRBBI2,RC = -0.79xCq + 31.99,-0.79,31.99,0.9989,0,36.49,25.3,2021-11-11 9 | OsCeBip,RC = -0.96xCq + 38.11,-0.96,38.11,0.9542,0,36.53,27.94,2021-11-11 10 | OsPOX223,RC = -1.01xCq + 35.04,-1.01,35.04,0.9996,0,33.07,22.78,2021-11-11 11 | OsPAL,RC = -0.86xCq + 31.96,-0.86,31.96,0.9998,0,35.02,23.01,2021-11-11 12 | OsAPX1,RC = -0.97xCq + 31.74,-0.97,31.74,0.9999,0,30.78,20.31,2021-11-11 13 | OsAPX2,RC = -0.87xCq + 31.16,-0.87,31.16,0.9942,0,35.42,22.11,2021-11-11 14 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/cal.expre.curve.sdc.txt: -------------------------------------------------------------------------------- 1 | Gene Formula Slope Intercept R2 P.value max.Cq min.Cq Date 2 | OsGns1 RC = -0.97xCq + 31.95 -0.97 31.95 0.9992 0 30.84 20.53 2021-11-11 3 | OsUBQ RC = -0.9xCq + 32.04 -0.9 32.04 0.9992 0 33.24 22.25 2021-11-11 4 | OsWRKY71 RC = -0.98xCq + 30.77 -0.98 30.77 0.9999 0 29.48 19.12 2021-11-11 5 | OSPOX8 RC = -0.91xCq + 34.48 -0.91 34.48 0.999 0 36.08 24.8 2021-11-11 6 | OsWAK91 RC = -0.91xCq + 36.77 -0.91 36.77 0.9954 0 34.75 27.12 2021-11-11 7 | OsPR10 RC = -0.99xCq + 41.22 -0.99 41.22 0.9695 0 36.3 29.39 2021-11-11 8 | OsRBBI2 RC = -0.79xCq + 31.99 -0.79 31.99 0.9989 0 36.49 25.3 2021-11-11 9 | OsCeBip RC = -0.96xCq + 38.11 -0.96 38.11 0.9542 0 36.53 27.94 2021-11-11 10 | OsPOX223 RC = -1.01xCq + 35.04 -1.01 35.04 0.9996 0 33.07 22.78 2021-11-11 11 | OsPAL RC = -0.86xCq + 31.96 -0.86 31.96 0.9998 0 35.02 23.01 2021-11-11 12 | OsAPX1 RC = -0.97xCq + 31.74 -0.97 31.74 0.9999 0 30.78 20.31 2021-11-11 13 | OsAPX2 RC = -0.87xCq + 31.16 -0.87 31.16 0.9942 0 35.42 22.11 2021-11-11 -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/cat.expre.curve.sdc.csv: -------------------------------------------------------------------------------- 1 | Gene,Formula,Slope,Intercept,R2,P.value,max,min,Date 2 | OsGns1,RC = -0.97xCq + 31.95,-0.97,31.95,0.9992,0,30.84,20.53,2021-11-11 3 | OsUBQ,RC = -0.9xCq + 32.04,-0.9,32.04,0.9992,0,33.24,22.25,2021-11-11 4 | OsWRKY71,RC = -0.98xCq + 30.77,-0.98,30.77,0.9999,0,29.48,19.12,2021-11-11 5 | OsPOX8,RC = -0.91xCq + 34.48,-0.91,34.48,0.999,0,36.08,24.8,2021-11-11 6 | OsWAK91,RC = -0.91xCq + 36.77,-0.91,36.77,0.9954,0,34.75,27.12,2021-11-11 7 | OsPR10,RC = -0.99xCq + 41.22,-0.99,41.22,0.9695,0,36.3,29.39,2021-11-11 8 | OsRBBI2,RC = -0.79xCq + 31.99,-0.79,31.99,0.9989,0,36.49,25.3,2021-11-11 9 | OsCeBip,RC = -0.96xCq + 38.11,-0.96,38.11,0.9542,0,36.53,27.94,2021-11-11 10 | OsPOX223,RC = -1.01xCq + 35.04,-1.01,35.04,0.9996,0,33.07,22.78,2021-11-11 11 | OsPAL,RC = -0.86xCq + 31.96,-0.86,31.96,0.9998,0,35.02,23.01,2021-11-11 12 | OsAPX1,RC = -0.97xCq + 31.74,-0.97,31.74,0.9999,0,30.78,20.31,2021-11-11 13 | OsAPX2,RC = -0.87xCq + 31.16,-0.87,31.16,0.9942,0,35.42,22.11,2021-11-11 14 | -------------------------------------------------------------------------------- /inst/examples/cal.expre.curve.sdc.csv: -------------------------------------------------------------------------------- 1 | Gene,Formula,Slope,Intercept,R2,P.value,max.Cq,min.Cq,Date 2 | OsGns1,RC = -0.97xCq + 31.95,-0.97,31.95,0.9992,0,30.84,20.53,2021-11-11 3 | OsUBQ,RC = -0.9xCq + 32.04,-0.9,32.04,0.9992,0,33.24,22.25,2021-11-11 4 | OsWRKY71,RC = -0.98xCq + 30.77,-0.98,30.77,0.9999,0,29.48,19.12,2021-11-11 5 | OsPOX8,RC = -0.91xCq + 34.48,-0.91,34.48,0.999,0,36.08,24.8,2021-11-11 6 | OsWAK91,RC = -0.91xCq + 36.77,-0.91,36.77,0.9954,0,34.75,27.12,2021-11-11 7 | OsPR10,RC = -0.99xCq + 41.22,-0.99,41.22,0.9695,0,36.3,29.39,2021-11-11 8 | OsRBBI2,RC = -0.79xCq + 31.99,-0.79,31.99,0.9989,0,36.49,25.3,2021-11-11 9 | OsCeBip,RC = -0.96xCq + 38.11,-0.96,38.11,0.9542,0,36.53,27.94,2021-11-11 10 | OsPOX223,RC = -1.01xCq + 35.04,-1.01,35.04,0.9996,0,33.07,22.78,2021-11-11 11 | OsPAL,RC = -0.86xCq + 31.96,-0.86,31.96,0.9998,0,35.02,23.01,2021-11-11 12 | OsAPX1,RC = -0.97xCq + 31.74,-0.97,31.74,0.9999,0,30.78,20.31,2021-11-11 13 | OsAPX2,RC = -0.87xCq + 31.16,-0.87,31.16,0.9942,0,35.42,22.11,2021-11-11 14 | ,,,,,,,, 15 | ,,,,,,,, 16 | ,,,,,,,,a 17 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/cal.expre.curve.sdc.csv: -------------------------------------------------------------------------------- 1 | Gene,Formula,Slope,Intercept,R2,P.value,max.Cq,min.Cq,Date 2 | OsGns1,RC = -0.97xCq + 31.95,-0.97,31.95,0.9992,0,30.84,20.53,2021-11-11 3 | OsUBQ,RC = -0.9xCq + 32.04,-0.9,32.04,0.9992,0,33.24,22.25,2021-11-11 4 | OsWRKY71,RC = -0.98xCq + 30.77,-0.98,30.77,0.9999,0,29.48,19.12,2021-11-11 5 | OsPOX8,RC = -0.91xCq + 34.48,-0.91,34.48,0.999,0,36.08,24.8,2021-11-11 6 | OsWAK91,RC = -0.91xCq + 36.77,-0.91,36.77,0.9954,0,34.75,27.12,2021-11-11 7 | OsPR10,RC = -0.99xCq + 41.22,-0.99,41.22,0.9695,0,36.3,29.39,2021-11-11 8 | OsRBBI2,RC = -0.79xCq + 31.99,-0.79,31.99,0.9989,0,36.49,25.3,2021-11-11 9 | OsCeBip,RC = -0.96xCq + 38.11,-0.96,38.11,0.9542,0,36.53,27.94,2021-11-11 10 | OsPOX223,RC = -1.01xCq + 35.04,-1.01,35.04,0.9996,0,33.07,22.78,2021-11-11 11 | OsPAL,RC = -0.86xCq + 31.96,-0.86,31.96,0.9998,0,35.02,23.01,2021-11-11 12 | OsAPX1,RC = -0.97xCq + 31.74,-0.97,31.74,0.9999,0,30.78,20.31,2021-11-11 13 | OsAPX2,RC = -0.87xCq + 31.16,-0.87,31.16,0.9942,0,35.42,22.11,2021-11-11 14 | ,,,,,,,, 15 | ,,,,,,,, 16 | ,,,,,,,,a 17 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/man/CalExp2dCt.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/CalExp2dCt.R 3 | \name{CalExp2dCt} 4 | \alias{CalExp2dCt} 5 | \title{Calculate expression using standard curve.} 6 | \arguments{ 7 | \item{cq.table}{The data frame of the position and cq value.} 8 | 9 | \item{design.table}{The data frame of the position and corresponding information.} 10 | 11 | \item{ref.gene}{The name of reference gene.} 12 | } 13 | \value{ 14 | A list contain a table and a figure. 15 | } 16 | \description{ 17 | Calculate expression using standard curve. 18 | } 19 | \examples{ 20 | df1.path <- system.file("examples", "dct.cq.txt", package = "qPCRtools") 21 | df2.path <- system.file("examples", "dct.design.txt", package = "qPCRtools") 22 | cq.table <- read.table(df1.path, sep = ",", header = TRUE) 23 | design.table <- read.table(df2.path, sep = ",", header = TRUE) 24 | CalExp2dCt(cq.table, 25 | design.table, 26 | ref.gene = "Actin" 27 | ) -> res 28 | 29 | } 30 | \author{ 31 | Xiang LI 32 | } 33 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2022 Xiang LI 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/ddct.cq.txt: -------------------------------------------------------------------------------- 1 | Position Cq 2 | A1 27.83 3 | A2 25.81 4 | A3 34.97 5 | A4 29.15 6 | A5 31.96 7 | A6 33.31 8 | A7 28.97 9 | A8 26.47 10 | A9 31.89 11 | A10 30.01 12 | A11 34.94 13 | A12 33.89 14 | B1 27.57 15 | B2 25.79 16 | B3 32.04 17 | B4 29.21 18 | B5 33 19 | B6 33.75 20 | B7 29.02 21 | B8 26.48 22 | B9 30.91 23 | B10 29.96 24 | B11 33.76 25 | B12 35.68 26 | C1 27.53 27 | C2 25.48 28 | C3 32.29 29 | C4 28.91 30 | C5 34.54 31 | C6 31.18 32 | C7 27.02 33 | C8 24.15 34 | C9 29.19 35 | C10 27.76 36 | C11 29.6 37 | C12 31.59 38 | D1 27.3 39 | D2 25.4 40 | D3 31.22 41 | D4 28.66 42 | D5 32.07 43 | D6 31.21 44 | D7 27.25 45 | D8 23.99 46 | D9 29.37 47 | D10 27.59 48 | D11 30.53 49 | D12 32 50 | E1 28.13 51 | E2 25.6 52 | E3 30.63 53 | E4 28.75 54 | E5 32.45 55 | E6 34.44 56 | E7 27.94 57 | E8 25.12 58 | E9 29.36 59 | E10 28.39 60 | E11 32.08 61 | E12 34.67 62 | F1 27.87 63 | F2 26.13 64 | F3 31.37 65 | F4 28.96 66 | F5 32.91 67 | F6 33.46 68 | F7 27.49 69 | F8 25.03 70 | F9 30 71 | F10 28.57 72 | F11 31.87 73 | F12 32.98 74 | G1 27.97 75 | G2 25.65 76 | G3 31.18 77 | G4 29.33 78 | G5 31.52 79 | G6 31.15 80 | G7 27.02 81 | G8 24.54 82 | G9 28.38 83 | G10 28.92 84 | G11 30.48 85 | G12 31.8 86 | H1 28.2 87 | H2 25.44 88 | H3 31.09 89 | H4 28.77 90 | H5 30.6 91 | H6 31.15 92 | H7 26.85 93 | H8 24.33 94 | H9 29.11 95 | H10 28.6 96 | H11 30.79 97 | H12 31.88 98 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/cal.exp.curve.cq.txt: -------------------------------------------------------------------------------- 1 | Position Cq 2 | A1 27.83 3 | A2 25.81 4 | A3 34.97 5 | A4 29.15 6 | A5 31.96 7 | A6 33.31 8 | A7 28.97 9 | A8 26.47 10 | A9 31.89 11 | A10 30.01 12 | A11 34.94 13 | A12 33.89 14 | B1 27.57 15 | B2 25.79 16 | B3 32.04 17 | B4 29.21 18 | B5 33 19 | B6 33.75 20 | B7 29.02 21 | B8 26.48 22 | B9 30.91 23 | B10 29.96 24 | B11 33.76 25 | B12 35.68 26 | C1 27.53 27 | C2 25.48 28 | C3 32.29 29 | C4 28.91 30 | C5 34.54 31 | C6 31.18 32 | C7 27.02 33 | C8 24.15 34 | C9 29.19 35 | C10 27.76 36 | C11 29.6 37 | C12 31.59 38 | D1 27.3 39 | D2 25.4 40 | D3 31.22 41 | D4 28.66 42 | D5 32.07 43 | D6 31.21 44 | D7 27.25 45 | D8 23.99 46 | D9 29.37 47 | D10 27.59 48 | D11 30.53 49 | D12 32 50 | E1 28.13 51 | E2 25.6 52 | E3 30.63 53 | E4 28.75 54 | E5 32.45 55 | E6 34.44 56 | E7 27.94 57 | E8 25.12 58 | E9 29.36 59 | E10 28.39 60 | E11 32.08 61 | E12 34.67 62 | F1 27.87 63 | F2 26.13 64 | F3 31.37 65 | F4 28.96 66 | F5 32.91 67 | F6 33.46 68 | F7 27.49 69 | F8 25.03 70 | F9 30 71 | F10 28.57 72 | F11 31.87 73 | F12 32.98 74 | G1 27.97 75 | G2 25.65 76 | G3 31.18 77 | G4 29.33 78 | G5 31.52 79 | G6 31.15 80 | G7 27.02 81 | G8 24.54 82 | G9 28.38 83 | G10 28.92 84 | G11 30.48 85 | G12 31.8 86 | H1 28.2 87 | H2 25.44 88 | H3 31.09 89 | H4 28.77 90 | H5 30.6 91 | H6 31.15 92 | H7 26.85 93 | H8 24.33 94 | H9 29.11 95 | H10 28.6 96 | H11 30.79 97 | H12 31.88 98 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/cal.expre.rqpcr.cq.txt: -------------------------------------------------------------------------------- 1 | Position Cq 2 | A1 27.83 3 | A2 25.81 4 | A3 34.97 5 | A4 29.15 6 | A5 31.96 7 | A6 33.31 8 | A7 28.97 9 | A8 26.47 10 | A9 31.89 11 | A10 30.01 12 | A11 34.94 13 | A12 33.89 14 | B1 27.57 15 | B2 25.79 16 | B3 32.04 17 | B4 29.21 18 | B5 33 19 | B6 33.75 20 | B7 29.02 21 | B8 26.48 22 | B9 30.91 23 | B10 29.96 24 | B11 33.76 25 | B12 35.68 26 | C1 27.53 27 | C2 25.48 28 | C3 32.29 29 | C4 28.91 30 | C5 34.54 31 | C6 31.18 32 | C7 27.02 33 | C8 24.15 34 | C9 29.19 35 | C10 27.76 36 | C11 29.6 37 | C12 31.59 38 | D1 27.3 39 | D2 25.4 40 | D3 31.22 41 | D4 28.66 42 | D5 32.07 43 | D6 31.21 44 | D7 27.25 45 | D8 23.99 46 | D9 29.37 47 | D10 27.59 48 | D11 30.53 49 | D12 32 50 | E1 28.13 51 | E2 25.6 52 | E3 30.63 53 | E4 28.75 54 | E5 32.45 55 | E6 34.44 56 | E7 27.94 57 | E8 25.12 58 | E9 29.36 59 | E10 28.39 60 | E11 32.08 61 | E12 34.67 62 | F1 27.87 63 | F2 26.13 64 | F3 31.37 65 | F4 28.96 66 | F5 32.91 67 | F6 33.46 68 | F7 27.49 69 | F8 25.03 70 | F9 30 71 | F10 28.57 72 | F11 31.87 73 | F12 32.98 74 | G1 27.97 75 | G2 25.65 76 | G3 31.18 77 | G4 29.33 78 | G5 31.52 79 | G6 31.15 80 | G7 27.02 81 | G8 24.54 82 | G9 28.38 83 | G10 28.92 84 | G11 30.48 85 | G12 31.8 86 | H1 28.2 87 | H2 25.44 88 | H3 31.09 89 | H4 28.77 90 | H5 30.6 91 | H6 31.15 92 | H7 26.85 93 | H8 24.33 94 | H9 29.11 95 | H10 28.6 96 | H11 30.79 97 | H12 31.88 98 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/man/CalRTable.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/CalRTable.R 3 | \name{CalRTable} 4 | \alias{CalRTable} 5 | \title{Calculate RNA volume for reverse transcription.} 6 | \arguments{ 7 | \item{data}{A data.frame contained the sample names and the concentration value. The default unit of concentration is ng/uL.} 8 | 9 | \item{template}{A data.frame contained the information of reverse transcription. In this data.frame there must be a column called `all`.} 10 | 11 | \item{RNA.weight}{RNA weight required for reverse transcription. Default is 1 ug.} 12 | } 13 | \value{ 14 | A list contain a table and a figure. 15 | } 16 | \description{ 17 | The first step of qPCR is usually the preparation of cDNA. 18 | We need to calculate the column of RNA for reverse transcription to cDNA. 19 | So, if we have the concentration of RNA, we can use the function `CalRTable` to do that. 20 | } 21 | \examples{ 22 | df.1.path <- system.file("examples", "crtv.data.txt", package = "qPCRtools") 23 | df.2.path <- system.file("examples", "crtv.template.txt", package = "qPCRtools") 24 | df.1 <- read.table(df.1.path, sep = "\t", header = TRUE) 25 | df.2 <- read.table(df.2.path, sep = "\t", header = TRUE) 26 | result <- CalRTable(data = df.1, template = df.2, RNA.weight = 2) 27 | head(result) 28 | } 29 | \author{ 30 | Xiang LI 31 | } 32 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/dct.cq.txt: -------------------------------------------------------------------------------- 1 | Position,Cq 2 | B16,38.07 3 | B22,33.68 4 | B10,33.01 5 | B4,30.3 6 | C22,28.71 7 | D24,28.11 8 | B23,27.78 9 | C10,27.69 10 | B11,27.63 11 | C24,27.12 12 | C23,27.04 13 | C11,26.33 14 | A24,26.2 15 | B21,26.17 16 | D22,26.04 17 | D19,25.97 18 | B24,25.86 19 | A20,25.76 20 | D21,25.72 21 | A21,25.68 22 | A8,25.56 23 | A19,25.49 24 | B20,25.31 25 | D23,25.06 26 | A9,24.96 27 | C12,24.76 28 | A23,24.68 29 | A11,24.56 30 | D12,24.46 31 | B19,24.34 32 | C20,24.31 33 | D10,24.29 34 | B12,24.12 35 | A22,24.1 36 | B7,24.09 37 | D7,23.8 38 | C8,23.63 39 | A7,23.62 40 | A10,23.58 41 | B9,23.29 42 | D18,23.28 43 | C18,23.09 44 | B17,23 45 | A12,22.74 46 | C17,22.71 47 | D11,22.71 48 | A18,22.37 49 | D20,22.34 50 | C16,22.32 51 | C14,22.22 52 | B15,22.21 53 | D13,22.2 54 | D9,22.17 55 | A13,22.16 56 | A17,22.16 57 | B14,21.88 58 | B13,21.85 59 | A16,21.84 60 | C21,21.71 61 | C19,21.7 62 | D15,21.67 63 | B18,21.65 64 | C7,21.51 65 | B8,21.23 66 | D8,21.13 67 | A15,21.09 68 | D16,21.01 69 | D17,21 70 | A14,19.99 71 | D14,19.95 72 | C13,19.79 73 | C9,19.25 74 | C15,18.72 75 | C2,18.58 76 | A1,18.49 77 | A4,18.33 78 | D6,18.28 79 | C6,18.13 80 | D5,17.73 81 | B5,17.68 82 | C4,17.67 83 | C1,17.48 84 | A3,17.31 85 | B3,17.3 86 | A6,17.09 87 | B6,17.07 88 | B2,16.89 89 | D2,16.81 90 | B1,16.63 91 | D4,16.53 92 | D3,16.49 93 | C5,16.32 94 | C3,16.31 95 | D1,16.23 96 | A2,16.16 97 | A5,16.14 98 | -------------------------------------------------------------------------------- /inst/examples/calsc.cq.txt: -------------------------------------------------------------------------------- 1 | Position Cq 2 | A1 27.26 3 | A2 27.1 4 | A3 27.47 5 | A4 21.2 6 | A5 21.11 7 | A6 21.06 8 | A7 17.63 9 | A8 17.670000000000002 10 | A9 17.73 11 | A10 22.53 12 | A11 22.51 13 | A12 22.89 14 | B1 27.41 15 | B2 27.33 16 | B3 27.42 17 | B4 22.36 18 | B5 22.31 19 | B6 22.35 20 | B7 19.79 21 | B8 19.59 22 | B9 19.649999999999999 23 | B10 22.13 24 | B11 22.06 25 | B12 22.12 26 | C1 29.7 27 | C2 29.52 28 | C3 29.22 29 | C4 24.5 30 | C5 24.5 31 | C6 24.66 32 | C7 22.37 33 | C8 22.07 34 | C9 22.26 35 | C10 24.27 36 | C11 24.42 37 | C12 24.52 38 | D1 31.43 39 | D2 31.11 40 | D3 31.4 41 | D4 26.52 42 | D5 26.62 43 | D6 26.68 44 | D7 24.42 45 | D8 24.47 46 | D9 24.38 47 | D10 26.58 48 | D11 26.77 49 | D12 26.8 50 | E1 33.93 51 | E2 33.729999999999997 52 | E3 33.79 53 | E4 28.6 54 | E5 29 55 | E6 28.98 56 | E7 26.91 57 | E8 26.9 58 | E9 26.8 59 | E10 28.62 60 | E11 28.92 61 | E12 29.15 62 | F1 39.82 63 | F2 40 64 | F3 40 65 | F4 30.79 66 | F5 30.85 67 | F6 30.15 68 | F7 28.69 69 | F8 28.83 70 | F9 28.77 71 | F10 31.07 72 | F11 31.17 73 | F12 31.17 74 | G1 35 75 | G2 35.29 76 | G3 35 77 | G4 32.25 78 | G5 33.89 79 | G6 32.6 80 | G7 31.39 81 | G8 30.63 82 | G9 30.91 83 | G10 32.840000000000003 84 | G11 32.99 85 | G12 33.44 86 | H1 36 87 | H2 36 88 | H3 36 89 | H4 34.590000000000003 90 | H5 38 91 | H6 37.840000000000003 92 | H7 37.950000000000003 93 | H8 38 94 | H9 36.25 95 | H10 36 96 | H11 36.03 97 | H12 35.369999999999997 98 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/calsc.cq.txt: -------------------------------------------------------------------------------- 1 | Position Cq 2 | A1 27.26 3 | A2 27.1 4 | A3 27.47 5 | A4 21.2 6 | A5 21.11 7 | A6 21.06 8 | A7 17.63 9 | A8 17.670000000000002 10 | A9 17.73 11 | A10 22.53 12 | A11 22.51 13 | A12 22.89 14 | B1 27.41 15 | B2 27.33 16 | B3 27.42 17 | B4 22.36 18 | B5 22.31 19 | B6 22.35 20 | B7 19.79 21 | B8 19.59 22 | B9 19.649999999999999 23 | B10 22.13 24 | B11 22.06 25 | B12 22.12 26 | C1 29.7 27 | C2 29.52 28 | C3 29.22 29 | C4 24.5 30 | C5 24.5 31 | C6 24.66 32 | C7 22.37 33 | C8 22.07 34 | C9 22.26 35 | C10 24.27 36 | C11 24.42 37 | C12 24.52 38 | D1 31.43 39 | D2 31.11 40 | D3 31.4 41 | D4 26.52 42 | D5 26.62 43 | D6 26.68 44 | D7 24.42 45 | D8 24.47 46 | D9 24.38 47 | D10 26.58 48 | D11 26.77 49 | D12 26.8 50 | E1 33.93 51 | E2 33.729999999999997 52 | E3 33.79 53 | E4 28.6 54 | E5 29 55 | E6 28.98 56 | E7 26.91 57 | E8 26.9 58 | E9 26.8 59 | E10 28.62 60 | E11 28.92 61 | E12 29.15 62 | F1 39.82 63 | F2 40 64 | F3 40 65 | F4 30.79 66 | F5 30.85 67 | F6 30.15 68 | F7 28.69 69 | F8 28.83 70 | F9 28.77 71 | F10 31.07 72 | F11 31.17 73 | F12 31.17 74 | G1 35 75 | G2 35.29 76 | G3 35 77 | G4 32.25 78 | G5 33.89 79 | G6 32.6 80 | G7 31.39 81 | G8 30.63 82 | G9 30.91 83 | G10 32.840000000000003 84 | G11 32.99 85 | G12 33.44 86 | H1 36 87 | H2 36 88 | H3 36 89 | H4 34.590000000000003 90 | H5 38 91 | H6 37.840000000000003 92 | H7 37.950000000000003 93 | H8 38 94 | H9 36.25 95 | H10 36 96 | H11 36.03 97 | H12 35.369999999999997 98 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/man/CalCurve.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/CalCurve.R 3 | \name{CalCurve} 4 | \alias{CalCurve} 5 | \title{Standard Curve Calculation.} 6 | \arguments{ 7 | \item{cq.table}{The data frame of the position and Cq value.} 8 | 9 | \item{concen.table}{The data frame of the position and concentration.} 10 | 11 | \item{highest.concen}{The highest concentration for calculation.} 12 | 13 | \item{lowest.concen}{The lowest concentration for calculation.} 14 | 15 | \item{dilution}{Dilution factor of cDNA template. The default value is 4.} 16 | 17 | \item{by.mean}{Calculation by mean Cq value or not. The default value is TRUE.} 18 | } 19 | \value{ 20 | A list. 21 | } 22 | \description{ 23 | The function can calculate the standard curve. 24 | At the same time, it can get the amplification efficiency of primer(s). 25 | Based on the amplification efficiency, we can know which method can be 26 | used to calculate the expression level. 27 | } 28 | \examples{ 29 | df.1.path <- system.file("examples", "calsc.cq.txt", package = "qPCRtools") 30 | df.2.path <- system.file("examples", "calsc.info.txt", package = "qPCRtools") 31 | df.1 <- read.table(df.1.path, header = TRUE) 32 | df.2 <- read.table(df.2.path, header = TRUE) 33 | CalCurve( 34 | cq.table = df.1, 35 | concen.table = df.2, 36 | lowest.concen = 4, 37 | highest.concen = 4096, 38 | dilu = 4, 39 | by = "mean" 40 | ) -> p 41 | 42 | p[["table"]] 43 | p[["figure"]] 44 | } 45 | \author{ 46 | Xiang LI 47 | } 48 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/man/CalExpRqPCR.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/CalExpRqPCR.R 3 | \name{CalExpRqPCR} 4 | \alias{CalExpRqPCR} 5 | \title{Calculate expression using standard curve.} 6 | \arguments{ 7 | \item{cq.table}{The data frame of the position and cq value.} 8 | 9 | \item{design.table}{The data frame of the position and corresponding information.} 10 | 11 | \item{correction}{Correct expression value by reference gene.} 12 | 13 | \item{ref.gene}{The name of reference gene.} 14 | 15 | \item{ref.group}{The name of reference group.} 16 | 17 | \item{stat.method}{Statistical method.} 18 | 19 | \item{fig.type}{Output image type, `box` represents `boxplot`, `bar` represents `barplot`.} 20 | 21 | \item{fig.ncol}{Number of columes of figure.} 22 | } 23 | \value{ 24 | A list contain a table and a figure. 25 | } 26 | \description{ 27 | Calculate expression using standard curve. 28 | } 29 | \examples{ 30 | df1.path <- system.file("examples", "cal.expre.rqpcr.cq.txt", package = "qPCRtools") 31 | df2.path <- system.file("examples", "cal.expre.rqpcr.design.txt", package = "qPCRtools") 32 | 33 | cq.table <- read.table(df1.path, header = TRUE) 34 | design.table <- read.table(df2.path, header = TRUE) 35 | 36 | CalExpRqPCR(cq.table, 37 | design.table, 38 | ref.gene = NULL, 39 | ref.group = "CK", 40 | stat.method = "t.test", 41 | fig.type = "box", 42 | fig.ncol = NULL 43 | ) -> res 44 | 45 | res[["table"]] 46 | res[["figure"]] 47 | 48 | } 49 | \author{ 50 | Xiang LI 51 | } 52 | -------------------------------------------------------------------------------- /inst/calsc.info.txt: -------------------------------------------------------------------------------- 1 | A1 Gene1 16384 2 | A2 Gene1 16384 3 | A3 Gene1 16384 4 | A4 Gene2 16384 5 | A5 Gene2 16384 6 | A6 Gene2 16384 7 | A7 Gene3 16384 8 | A8 Gene3 16384 9 | A9 Gene3 16384 10 | A10 Gene4 16384 11 | A11 Gene4 16384 12 | A12 Gene4 16384 13 | B1 Gene1 4096 14 | B2 Gene1 4096 15 | B3 Gene1 4096 16 | B4 Gene2 4096 17 | B5 Gene2 4096 18 | B6 Gene2 4096 19 | B7 Gene3 4096 20 | B8 Gene3 4096 21 | B9 Gene3 4096 22 | B10 Gene4 4096 23 | B11 Gene4 4096 24 | B12 Gene4 4096 25 | C1 Gene1 1024 26 | C2 Gene1 1024 27 | C3 Gene1 1024 28 | C4 Gene2 1024 29 | C5 Gene2 1024 30 | C6 Gene2 1024 31 | C7 Gene3 1024 32 | C8 Gene3 1024 33 | C9 Gene3 1024 34 | C10 Gene4 1024 35 | C11 Gene4 1024 36 | C12 Gene4 1024 37 | D1 Gene1 256 38 | D2 Gene1 256 39 | D3 Gene1 256 40 | D4 Gene2 256 41 | D5 Gene2 256 42 | D6 Gene2 256 43 | D7 Gene3 256 44 | D8 Gene3 256 45 | D9 Gene3 256 46 | D10 Gene4 256 47 | D11 Gene4 256 48 | D12 Gene4 256 49 | E1 Gene1 64 50 | E2 Gene1 64 51 | E3 Gene1 64 52 | E4 Gene2 64 53 | E5 Gene2 64 54 | E6 Gene2 64 55 | E7 Gene3 64 56 | E8 Gene3 64 57 | E9 Gene3 64 58 | E10 Gene4 64 59 | E11 Gene4 64 60 | E12 Gene4 64 61 | F1 Gene1 16 62 | F2 Gene1 16 63 | F3 Gene1 16 64 | F4 Gene2 16 65 | F5 Gene2 16 66 | F6 Gene2 16 67 | F7 Gene3 16 68 | F8 Gene3 16 69 | F9 Gene3 16 70 | F10 Gene4 16 71 | F11 Gene4 16 72 | F12 Gene4 16 73 | G1 Gene1 4 74 | G2 Gene1 4 75 | G3 Gene1 4 76 | G4 Gene2 4 77 | G5 Gene2 4 78 | G6 Gene2 4 79 | G7 Gene3 4 80 | G8 Gene3 4 81 | G9 Gene3 4 82 | G10 Gene4 4 83 | G11 Gene4 4 84 | G12 Gene4 4 85 | H1 Gene1 1 86 | H2 Gene1 1 87 | H3 Gene1 1 88 | H4 Gene2 1 89 | H5 Gene2 1 90 | H6 Gene2 1 91 | H7 Gene3 1 92 | H8 Gene3 1 93 | H9 Gene3 1 94 | H10 Gene4 1 95 | H11 Gene4 1 96 | H12 Gene4 1 97 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/man/CalExp2ddCt.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/CalExp2ddCt.R 3 | \name{CalExp2ddCt} 4 | \alias{CalExp2ddCt} 5 | \title{Calculate expression using standard curve.} 6 | \arguments{ 7 | \item{cq.table}{The data frame of the position and cq value.} 8 | 9 | \item{design.table}{The data frame of the position and corresponding information.} 10 | 11 | \item{correction}{Correct expression value by reference gene.} 12 | 13 | \item{ref.gene}{The name of reference gene.} 14 | 15 | \item{ref.group}{The name of reference group.} 16 | 17 | \item{stat.method}{Statistical method.} 18 | 19 | \item{remove.outliers}{Remove the outliers of each group and gene, or not.} 20 | 21 | \item{fig.type}{Output image type, `box` represents `boxplot`, `bar` represents `barplot`.} 22 | 23 | \item{fig.ncol}{Number of columes of figure.} 24 | } 25 | \value{ 26 | A list contain a table and a figure. 27 | } 28 | \description{ 29 | Calculate expression using standard curve. 30 | } 31 | \examples{ 32 | df1.path = system.file("examples", "ddct.cq.txt", package = "qPCRtools") 33 | df2.path = system.file("examples", "ddct.design.txt", package = "qPCRtools") 34 | 35 | cq.table = read.table(df1.path, header = TRUE) 36 | design.table = read.table(df2.path, header = TRUE) 37 | 38 | CalExp2ddCt(cq.table, 39 | design.table, 40 | ref.gene = "OsUBQ", 41 | ref.group = "CK", 42 | stat.method = "t.test", 43 | remove.outliers = TRUE, 44 | fig.type = "box", 45 | fig.ncol = NULL) -> res 46 | 47 | res[["table"]] 48 | res[["figure"]] 49 | 50 | } 51 | \author{ 52 | Xiang LI 53 | } 54 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/calsc.info.txt: -------------------------------------------------------------------------------- 1 | A1 Gene1 16384 2 | A2 Gene1 16384 3 | A3 Gene1 16384 4 | A4 Gene2 16384 5 | A5 Gene2 16384 6 | A6 Gene2 16384 7 | A7 Gene3 16384 8 | A8 Gene3 16384 9 | A9 Gene3 16384 10 | A10 Gene4 16384 11 | A11 Gene4 16384 12 | A12 Gene4 16384 13 | B1 Gene1 4096 14 | B2 Gene1 4096 15 | B3 Gene1 4096 16 | B4 Gene2 4096 17 | B5 Gene2 4096 18 | B6 Gene2 4096 19 | B7 Gene3 4096 20 | B8 Gene3 4096 21 | B9 Gene3 4096 22 | B10 Gene4 4096 23 | B11 Gene4 4096 24 | B12 Gene4 4096 25 | C1 Gene1 1024 26 | C2 Gene1 1024 27 | C3 Gene1 1024 28 | C4 Gene2 1024 29 | C5 Gene2 1024 30 | C6 Gene2 1024 31 | C7 Gene3 1024 32 | C8 Gene3 1024 33 | C9 Gene3 1024 34 | C10 Gene4 1024 35 | C11 Gene4 1024 36 | C12 Gene4 1024 37 | D1 Gene1 256 38 | D2 Gene1 256 39 | D3 Gene1 256 40 | D4 Gene2 256 41 | D5 Gene2 256 42 | D6 Gene2 256 43 | D7 Gene3 256 44 | D8 Gene3 256 45 | D9 Gene3 256 46 | D10 Gene4 256 47 | D11 Gene4 256 48 | D12 Gene4 256 49 | E1 Gene1 64 50 | E2 Gene1 64 51 | E3 Gene1 64 52 | E4 Gene2 64 53 | E5 Gene2 64 54 | E6 Gene2 64 55 | E7 Gene3 64 56 | E8 Gene3 64 57 | E9 Gene3 64 58 | E10 Gene4 64 59 | E11 Gene4 64 60 | E12 Gene4 64 61 | F1 Gene1 16 62 | F2 Gene1 16 63 | F3 Gene1 16 64 | F4 Gene2 16 65 | F5 Gene2 16 66 | F6 Gene2 16 67 | F7 Gene3 16 68 | F8 Gene3 16 69 | F9 Gene3 16 70 | F10 Gene4 16 71 | F11 Gene4 16 72 | F12 Gene4 16 73 | G1 Gene1 4 74 | G2 Gene1 4 75 | G3 Gene1 4 76 | G4 Gene2 4 77 | G5 Gene2 4 78 | G6 Gene2 4 79 | G7 Gene3 4 80 | G8 Gene3 4 81 | G9 Gene3 4 82 | G10 Gene4 4 83 | G11 Gene4 4 84 | G12 Gene4 4 85 | H1 Gene1 1 86 | H2 Gene1 1 87 | H3 Gene1 1 88 | H4 Gene2 1 89 | H5 Gene2 1 90 | H6 Gene2 1 91 | H7 Gene3 1 92 | H8 Gene3 1 93 | H9 Gene3 1 94 | H10 Gene4 1 95 | H11 Gene4 1 96 | H12 Gene4 1 97 | -------------------------------------------------------------------------------- /inst/examples/calsc.info.txt: -------------------------------------------------------------------------------- 1 | Position Gene Conc 2 | A1 Gene1 16384 3 | A2 Gene1 16384 4 | A3 Gene1 16384 5 | A4 Gene2 16384 6 | A5 Gene2 16384 7 | A6 Gene2 16384 8 | A7 Gene3 16384 9 | A8 Gene3 16384 10 | A9 Gene3 16384 11 | A10 Gene4 16384 12 | A11 Gene4 16384 13 | A12 Gene4 16384 14 | B1 Gene1 4096 15 | B2 Gene1 4096 16 | B3 Gene1 4096 17 | B4 Gene2 4096 18 | B5 Gene2 4096 19 | B6 Gene2 4096 20 | B7 Gene3 4096 21 | B8 Gene3 4096 22 | B9 Gene3 4096 23 | B10 Gene4 4096 24 | B11 Gene4 4096 25 | B12 Gene4 4096 26 | C1 Gene1 1024 27 | C2 Gene1 1024 28 | C3 Gene1 1024 29 | C4 Gene2 1024 30 | C5 Gene2 1024 31 | C6 Gene2 1024 32 | C7 Gene3 1024 33 | C8 Gene3 1024 34 | C9 Gene3 1024 35 | C10 Gene4 1024 36 | C11 Gene4 1024 37 | C12 Gene4 1024 38 | D1 Gene1 256 39 | D2 Gene1 256 40 | D3 Gene1 256 41 | D4 Gene2 256 42 | D5 Gene2 256 43 | D6 Gene2 256 44 | D7 Gene3 256 45 | D8 Gene3 256 46 | D9 Gene3 256 47 | D10 Gene4 256 48 | D11 Gene4 256 49 | D12 Gene4 256 50 | E1 Gene1 64 51 | E2 Gene1 64 52 | E3 Gene1 64 53 | E4 Gene2 64 54 | E5 Gene2 64 55 | E6 Gene2 64 56 | E7 Gene3 64 57 | E8 Gene3 64 58 | E9 Gene3 64 59 | E10 Gene4 64 60 | E11 Gene4 64 61 | E12 Gene4 64 62 | F1 Gene1 16 63 | F2 Gene1 16 64 | F3 Gene1 16 65 | F4 Gene2 16 66 | F5 Gene2 16 67 | F6 Gene2 16 68 | F7 Gene3 16 69 | F8 Gene3 16 70 | F9 Gene3 16 71 | F10 Gene4 16 72 | F11 Gene4 16 73 | F12 Gene4 16 74 | G1 Gene1 4 75 | G2 Gene1 4 76 | G3 Gene1 4 77 | G4 Gene2 4 78 | G5 Gene2 4 79 | G6 Gene2 4 80 | G7 Gene3 4 81 | G8 Gene3 4 82 | G9 Gene3 4 83 | G10 Gene4 4 84 | G11 Gene4 4 85 | G12 Gene4 4 86 | H1 Gene1 1 87 | H2 Gene1 1 88 | H3 Gene1 1 89 | H4 Gene2 1 90 | H5 Gene2 1 91 | H6 Gene2 1 92 | H7 Gene3 1 93 | H8 Gene3 1 94 | H9 Gene3 1 95 | H10 Gene4 1 96 | H11 Gene4 1 97 | H12 Gene4 1 98 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/calsc.info.txt: -------------------------------------------------------------------------------- 1 | Position Gene Conc 2 | A1 Gene1 16384 3 | A2 Gene1 16384 4 | A3 Gene1 16384 5 | A4 Gene2 16384 6 | A5 Gene2 16384 7 | A6 Gene2 16384 8 | A7 Gene3 16384 9 | A8 Gene3 16384 10 | A9 Gene3 16384 11 | A10 Gene4 16384 12 | A11 Gene4 16384 13 | A12 Gene4 16384 14 | B1 Gene1 4096 15 | B2 Gene1 4096 16 | B3 Gene1 4096 17 | B4 Gene2 4096 18 | B5 Gene2 4096 19 | B6 Gene2 4096 20 | B7 Gene3 4096 21 | B8 Gene3 4096 22 | B9 Gene3 4096 23 | B10 Gene4 4096 24 | B11 Gene4 4096 25 | B12 Gene4 4096 26 | C1 Gene1 1024 27 | C2 Gene1 1024 28 | C3 Gene1 1024 29 | C4 Gene2 1024 30 | C5 Gene2 1024 31 | C6 Gene2 1024 32 | C7 Gene3 1024 33 | C8 Gene3 1024 34 | C9 Gene3 1024 35 | C10 Gene4 1024 36 | C11 Gene4 1024 37 | C12 Gene4 1024 38 | D1 Gene1 256 39 | D2 Gene1 256 40 | D3 Gene1 256 41 | D4 Gene2 256 42 | D5 Gene2 256 43 | D6 Gene2 256 44 | D7 Gene3 256 45 | D8 Gene3 256 46 | D9 Gene3 256 47 | D10 Gene4 256 48 | D11 Gene4 256 49 | D12 Gene4 256 50 | E1 Gene1 64 51 | E2 Gene1 64 52 | E3 Gene1 64 53 | E4 Gene2 64 54 | E5 Gene2 64 55 | E6 Gene2 64 56 | E7 Gene3 64 57 | E8 Gene3 64 58 | E9 Gene3 64 59 | E10 Gene4 64 60 | E11 Gene4 64 61 | E12 Gene4 64 62 | F1 Gene1 16 63 | F2 Gene1 16 64 | F3 Gene1 16 65 | F4 Gene2 16 66 | F5 Gene2 16 67 | F6 Gene2 16 68 | F7 Gene3 16 69 | F8 Gene3 16 70 | F9 Gene3 16 71 | F10 Gene4 16 72 | F11 Gene4 16 73 | F12 Gene4 16 74 | G1 Gene1 4 75 | G2 Gene1 4 76 | G3 Gene1 4 77 | G4 Gene2 4 78 | G5 Gene2 4 79 | G6 Gene2 4 80 | G7 Gene3 4 81 | G8 Gene3 4 82 | G9 Gene3 4 83 | G10 Gene4 4 84 | G11 Gene4 4 85 | G12 Gene4 4 86 | H1 Gene1 1 87 | H2 Gene1 1 88 | H3 Gene1 1 89 | H4 Gene2 1 90 | H5 Gene2 1 91 | H6 Gene2 1 92 | H7 Gene3 1 93 | H8 Gene3 1 94 | H9 Gene3 1 95 | H10 Gene4 1 96 | H11 Gene4 1 97 | H12 Gene4 1 98 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/man/CalExpCurve.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/CalExpCurve.R 3 | \name{CalExpCurve} 4 | \alias{CalExpCurve} 5 | \title{Calculate expression using standard curve.} 6 | \arguments{ 7 | \item{cq.table}{The data frame of the position and Cq value.} 8 | 9 | \item{design.table}{The data frame of the position and corresponding information.} 10 | 11 | \item{correction}{Correct expression value by reference gene.} 12 | 13 | \item{ref.gene}{The name of reference gene.} 14 | 15 | \item{stat.method}{Statistical method.} 16 | 17 | \item{ref.group}{The name of reference group.} 18 | 19 | \item{fig.type}{Output image type, `box` represents `boxplot`, `bar` represents `barplot`.} 20 | 21 | \item{fig.ncol}{Number of columes of figure.} 22 | } 23 | \value{ 24 | A list contain a table and a figure. 25 | } 26 | \description{ 27 | Calculate expression using standard curve. 28 | } 29 | \examples{ 30 | df1.path = system.file("examples", "cal.exp.curve.cq.txt", package = "qPCRtools") 31 | df2.path = system.file("examples", "cal.expre.curve.sdc.txt", package = "qPCRtools") 32 | df3.path = system.file("examples", "cal.exp.curve.design.txt", package = "qPCRtools") 33 | 34 | cq.table = read.table(df1.path, header = TRUE) 35 | curve.table = read.table(df2.path, sep = "\t", header = TRUE) 36 | design.table = read.table(df3.path, header = TRUE) 37 | 38 | CalExpCurve( 39 | cq.table, 40 | curve.table, 41 | design.table, 42 | correction = TRUE, 43 | ref.gene = "OsUBQ", 44 | stat.method = "t.test", 45 | ref.group = "CK", 46 | fig.type = "box", 47 | fig.ncol = NULL) -> res 48 | 49 | res[["table"]] 50 | res[["figure"]] 51 | 52 | } 53 | \author{ 54 | Xiang LI 55 | } 56 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/dct.design.txt: -------------------------------------------------------------------------------- 1 | Position,Group,Gene,BioRep 2 | A1,15,Actin,1 3 | A2,15,Actin,3 4 | A3,15,Actin,5 5 | A4,49,Actin,1 6 | A5,49,Actin,3 7 | A6,49,Actin,5 8 | A7,15,Pr1b,1 9 | A8,15,Pr1b,3 10 | A9,15,Pr1b,5 11 | A10,49,Pr1b,1 12 | A11,49,Pr1b,3 13 | A12,49,Pr1b,5 14 | A13,15,PBZ1,1 15 | A14,15,PBZ1,3 16 | A15,15,PBZ1,5 17 | A16,49,PBZ1,1 18 | A17,49,PBZ1,3 19 | A18,49,PBZ1,5 20 | A19,15,CHI,1 21 | A20,15,CHI,3 22 | A21,15,CHI,5 23 | A22,49,CHI,1 24 | A23,49,CHI,3 25 | A24,49,CHI,5 26 | B1,15,Actin,2 27 | B2,15,Actin,4 28 | B3,15,Actin,6 29 | B4,49,Actin,2 30 | B5,49,Actin,4 31 | B6,49,Actin,6 32 | B7,15,Pr1b,2 33 | B8,15,Pr1b,4 34 | B9,15,Pr1b,6 35 | B10,49,Pr1b,2 36 | B11,49,Pr1b,4 37 | B12,49,Pr1b,6 38 | B13,15,PBZ1,2 39 | B14,15,PBZ1,4 40 | B15,15,PBZ1,6 41 | B16,49,PBZ1,2 42 | B17,49,PBZ1,4 43 | B18,49,PBZ1,6 44 | B19,15,CHI,2 45 | B20,15,CHI,4 46 | B21,15,CHI,6 47 | B22,49,CHI,2 48 | B23,49,CHI,4 49 | B24,49,CHI,6 50 | C1,69,Actin,1 51 | C2,69,Actin,3 52 | C3,69,Actin,5 53 | C4,87,Actin,1 54 | C5,87,Actin,3 55 | C6,87,Actin,5 56 | C7,69,Pr1b,1 57 | C8,69,Pr1b,3 58 | C9,69,Pr1b,5 59 | C10,87,Pr1b,1 60 | C11,87,Pr1b,3 61 | C12,87,Pr1b,5 62 | C13,69,PBZ1,1 63 | C14,69,PBZ1,3 64 | C15,69,PBZ1,5 65 | C16,87,PBZ1,1 66 | C17,87,PBZ1,3 67 | C18,87,PBZ1,5 68 | C19,69,CHI,1 69 | C20,69,CHI,3 70 | C21,69,CHI,5 71 | C22,87,CHI,1 72 | C23,87,CHI,3 73 | C24,87,CHI,5 74 | D1,69,Actin,2 75 | D2,69,Actin,4 76 | D3,69,Actin,6 77 | D4,87,Actin,2 78 | D5,87,Actin,4 79 | D6,87,Actin,6 80 | D7,69,Pr1b,2 81 | D8,69,Pr1b,4 82 | D9,69,Pr1b,6 83 | D10,87,Pr1b,2 84 | D11,87,Pr1b,4 85 | D12,87,Pr1b,6 86 | D13,69,PBZ1,2 87 | D14,69,PBZ1,4 88 | D15,69,PBZ1,6 89 | D16,87,PBZ1,2 90 | D17,87,PBZ1,4 91 | D18,87,PBZ1,6 92 | D19,69,CHI,2 93 | D20,69,CHI,4 94 | D21,69,CHI,6 95 | D22,87,CHI,2 96 | D23,87,CHI,4 97 | D24,87,CHI,6 98 | -------------------------------------------------------------------------------- /inst/examples/cal.exp.curve.design.csv: -------------------------------------------------------------------------------- 1 | Position,Treatment,Gene 2 | A1,CK,OSPOX8 3 | A2,CK,OsUBQ 4 | A3,CK,OsWAK91 5 | A4,CK,OsRBBI2 6 | A5,CK,OsCeBip 7 | A6,CK,OsPR10 8 | A7,Treatment,OSPOX8 9 | A8,Treatment,OsUBQ 10 | A9,Treatment,OsWAK91 11 | A10,Treatment,OsRBBI2 12 | A11,Treatment,OsCeBip 13 | A12,Treatment,OsPR10 14 | B1,CK,OSPOX8 15 | B2,CK,OsUBQ 16 | B3,CK,OsWAK91 17 | B4,CK,OsRBBI2 18 | B5,CK,OsCeBip 19 | B6,CK,OsPR10 20 | B7,Treatment,OSPOX8 21 | B8,Treatment,OsUBQ 22 | B9,Treatment,OsWAK91 23 | B10,Treatment,OsRBBI2 24 | B11,Treatment,OsCeBip 25 | B12,Treatment,OsPR10 26 | C1,CK,OSPOX8 27 | C2,CK,OsUBQ 28 | C3,CK,OsWAK91 29 | C4,CK,OsRBBI2 30 | C5,CK,OsCeBip 31 | C6,CK,OsPR10 32 | C7,Treatment,OSPOX8 33 | C8,Treatment,OsUBQ 34 | C9,Treatment,OsWAK91 35 | C10,Treatment,OsRBBI2 36 | C11,Treatment,OsCeBip 37 | C12,Treatment,OsPR10 38 | D1,CK,OSPOX8 39 | D2,CK,OsUBQ 40 | D3,CK,OsWAK91 41 | D4,CK,OsRBBI2 42 | D5,CK,OsCeBip 43 | D6,CK,OsPR10 44 | D7,Treatment,OSPOX8 45 | D8,Treatment,OsUBQ 46 | D9,Treatment,OsWAK91 47 | D10,Treatment,OsRBBI2 48 | D11,Treatment,OsCeBip 49 | D12,Treatment,OsPR10 50 | E1,CK,OSPOX8 51 | E2,CK,OsUBQ 52 | E3,CK,OsWAK91 53 | E4,CK,OsRBBI2 54 | E5,CK,OsCeBip 55 | E6,CK,OsPR10 56 | E7,Treatment,OSPOX8 57 | E8,Treatment,OsUBQ 58 | E9,Treatment,OsWAK91 59 | E10,Treatment,OsRBBI2 60 | E11,Treatment,OsCeBip 61 | E12,Treatment,OsPR10 62 | F1,CK,OSPOX8 63 | F2,CK,OsUBQ 64 | F3,CK,OsWAK91 65 | F4,CK,OsRBBI2 66 | F5,CK,OsCeBip 67 | F6,CK,OsPR10 68 | F7,Treatment,OSPOX8 69 | F8,Treatment,OsUBQ 70 | F9,Treatment,OsWAK91 71 | F10,Treatment,OsRBBI2 72 | F11,Treatment,OsCeBip 73 | F12,Treatment,OsPR10 74 | G1,CK,OSPOX8 75 | G2,CK,OsUBQ 76 | G3,CK,OsWAK91 77 | G4,CK,OsRBBI2 78 | G5,CK,OsCeBip 79 | G6,CK,OsPR10 80 | G7,Treatment,OSPOX8 81 | G8,Treatment,OsUBQ 82 | G9,Treatment,OsWAK91 83 | G10,Treatment,OsRBBI2 84 | G11,Treatment,OsCeBip 85 | G12,Treatment,OsPR10 86 | H1,CK,OSPOX8 87 | H2,CK,OsUBQ 88 | H3,CK,OsWAK91 89 | H4,CK,OsRBBI2 90 | H5,CK,OsCeBip 91 | H6,CK,OsPR10 92 | H7,Treatment,OSPOX8 93 | H8,Treatment,OsUBQ 94 | H9,Treatment,OsWAK91 95 | H10,Treatment,OsRBBI2 96 | H11,Treatment,OsCeBip 97 | H12,Treatment,OsPR10 98 | -------------------------------------------------------------------------------- /R/CalRTable.R: -------------------------------------------------------------------------------- 1 | #' @name CalRTable 2 | #' @author Xiang LI 3 | #' @title Calculate RNA volume for reverse transcription. 4 | #' @description The first step of qPCR is usually the preparation of cDNA. 5 | #' We need to calculate the column of RNA for reverse transcription to cDNA. 6 | #' So, if we have the concentration of RNA, we can use the function `CalRTable` to do that. 7 | #' 8 | #' @param data A data.frame contained the sample names and the concentration value. The default unit of concentration is ng/uL. 9 | #' @param template A data.frame contained the information of reverse transcription. In this data.frame there must be a column called `all`. 10 | #' @param RNA.weight RNA weight required for reverse transcription. Default is 1 ug. 11 | #' 12 | #' @importFrom dplyr select rename group_by mutate ungroup 13 | #' @importFrom magrittr %>% 14 | #' 15 | #' @export 16 | #' 17 | #' @examples 18 | #' df.1.path <- system.file("examples", "crtv.data.txt", package = "qPCRtools") 19 | #' df.2.path <- system.file("examples", "crtv.template.txt", package = "qPCRtools") 20 | #' df.1 <- read.table(df.1.path, sep = "\t", header = TRUE) 21 | #' df.2 <- read.table(df.2.path, sep = "\t", header = TRUE) 22 | #' result <- CalRTable(data = df.1, template = df.2, RNA.weight = 2) 23 | #' head(result) 24 | #' @return A list contain a table and a figure. 25 | globalVariables(c("data", "template", "RNA.weight", 26 | "df.1", "sum.temp", "sample", 27 | "concentration", "volume.RNA", 28 | "mean","volume.h2o","all", 29 | "sum.temp","volume.RNA", 30 | "df.2")) 31 | CalRTable <- function(data, template, RNA.weight = 1) { 32 | df.1 <- template * RNA.weight 33 | 34 | sum.temp <- rowSums(df.1[1, ]) - df.1$all 35 | 36 | df.2 <- data %>% 37 | dplyr::group_by(sample) %>% 38 | dplyr::summarise(mean = mean(concentration)) %>% 39 | dplyr::ungroup() %>% 40 | dplyr::mutate(volume.RNA = RNA.weight / mean * 1000) %>% 41 | cbind(df.1) %>% 42 | dplyr::mutate(volume.h2o = all - sum.temp - volume.RNA) 43 | return(df.2) 44 | } 45 | 46 | 47 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/cal.exp.curve.design.csv: -------------------------------------------------------------------------------- 1 | Position,Treatment,Gene 2 | A1,CK,OSPOX8 3 | A2,CK,OsUBQ 4 | A3,CK,OsWAK91 5 | A4,CK,OsRBBI2 6 | A5,CK,OsCeBip 7 | A6,CK,OsPR10 8 | A7,Treatment,OSPOX8 9 | A8,Treatment,OsUBQ 10 | A9,Treatment,OsWAK91 11 | A10,Treatment,OsRBBI2 12 | A11,Treatment,OsCeBip 13 | A12,Treatment,OsPR10 14 | B1,CK,OSPOX8 15 | B2,CK,OsUBQ 16 | B3,CK,OsWAK91 17 | B4,CK,OsRBBI2 18 | B5,CK,OsCeBip 19 | B6,CK,OsPR10 20 | B7,Treatment,OSPOX8 21 | B8,Treatment,OsUBQ 22 | B9,Treatment,OsWAK91 23 | B10,Treatment,OsRBBI2 24 | B11,Treatment,OsCeBip 25 | B12,Treatment,OsPR10 26 | C1,CK,OSPOX8 27 | C2,CK,OsUBQ 28 | C3,CK,OsWAK91 29 | C4,CK,OsRBBI2 30 | C5,CK,OsCeBip 31 | C6,CK,OsPR10 32 | C7,Treatment,OSPOX8 33 | C8,Treatment,OsUBQ 34 | C9,Treatment,OsWAK91 35 | C10,Treatment,OsRBBI2 36 | C11,Treatment,OsCeBip 37 | C12,Treatment,OsPR10 38 | D1,CK,OSPOX8 39 | D2,CK,OsUBQ 40 | D3,CK,OsWAK91 41 | D4,CK,OsRBBI2 42 | D5,CK,OsCeBip 43 | D6,CK,OsPR10 44 | D7,Treatment,OSPOX8 45 | D8,Treatment,OsUBQ 46 | D9,Treatment,OsWAK91 47 | D10,Treatment,OsRBBI2 48 | D11,Treatment,OsCeBip 49 | D12,Treatment,OsPR10 50 | E1,CK,OSPOX8 51 | E2,CK,OsUBQ 52 | E3,CK,OsWAK91 53 | E4,CK,OsRBBI2 54 | E5,CK,OsCeBip 55 | E6,CK,OsPR10 56 | E7,Treatment,OSPOX8 57 | E8,Treatment,OsUBQ 58 | E9,Treatment,OsWAK91 59 | E10,Treatment,OsRBBI2 60 | E11,Treatment,OsCeBip 61 | E12,Treatment,OsPR10 62 | F1,CK,OSPOX8 63 | F2,CK,OsUBQ 64 | F3,CK,OsWAK91 65 | F4,CK,OsRBBI2 66 | F5,CK,OsCeBip 67 | F6,CK,OsPR10 68 | F7,Treatment,OSPOX8 69 | F8,Treatment,OsUBQ 70 | F9,Treatment,OsWAK91 71 | F10,Treatment,OsRBBI2 72 | F11,Treatment,OsCeBip 73 | F12,Treatment,OsPR10 74 | G1,CK,OSPOX8 75 | G2,CK,OsUBQ 76 | G3,CK,OsWAK91 77 | G4,CK,OsRBBI2 78 | G5,CK,OsCeBip 79 | G6,CK,OsPR10 80 | G7,Treatment,OSPOX8 81 | G8,Treatment,OsUBQ 82 | G9,Treatment,OsWAK91 83 | G10,Treatment,OsRBBI2 84 | G11,Treatment,OsCeBip 85 | G12,Treatment,OsPR10 86 | H1,CK,OSPOX8 87 | H2,CK,OsUBQ 88 | H3,CK,OsWAK91 89 | H4,CK,OsRBBI2 90 | H5,CK,OsCeBip 91 | H6,CK,OsPR10 92 | H7,Treatment,OSPOX8 93 | H8,Treatment,OsUBQ 94 | H9,Treatment,OsWAK91 95 | H10,Treatment,OsRBBI2 96 | H11,Treatment,OsCeBip 97 | H12,Treatment,OsPR10 98 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/cal.exp.curve.design.txt: -------------------------------------------------------------------------------- 1 | Position Treatment Gene 2 | A1 CK OSPOX8 3 | A2 CK OsUBQ 4 | A3 CK OsWAK91 5 | A4 CK OsRBBI2 6 | A5 CK OsCeBip 7 | A6 CK OsPR10 8 | A7 Treatment OSPOX8 9 | A8 Treatment OsUBQ 10 | A9 Treatment OsWAK91 11 | A10 Treatment OsRBBI2 12 | A11 Treatment OsCeBip 13 | A12 Treatment OsPR10 14 | B1 CK OSPOX8 15 | B2 CK OsUBQ 16 | B3 CK OsWAK91 17 | B4 CK OsRBBI2 18 | B5 CK OsCeBip 19 | B6 CK OsPR10 20 | B7 Treatment OSPOX8 21 | B8 Treatment OsUBQ 22 | B9 Treatment OsWAK91 23 | B10 Treatment OsRBBI2 24 | B11 Treatment OsCeBip 25 | B12 Treatment OsPR10 26 | C1 CK OSPOX8 27 | C2 CK OsUBQ 28 | C3 CK OsWAK91 29 | C4 CK OsRBBI2 30 | C5 CK OsCeBip 31 | C6 CK OsPR10 32 | C7 Treatment OSPOX8 33 | C8 Treatment OsUBQ 34 | C9 Treatment OsWAK91 35 | C10 Treatment OsRBBI2 36 | C11 Treatment OsCeBip 37 | C12 Treatment OsPR10 38 | D1 CK OSPOX8 39 | D2 CK OsUBQ 40 | D3 CK OsWAK91 41 | D4 CK OsRBBI2 42 | D5 CK OsCeBip 43 | D6 CK OsPR10 44 | D7 Treatment OSPOX8 45 | D8 Treatment OsUBQ 46 | D9 Treatment OsWAK91 47 | D10 Treatment OsRBBI2 48 | D11 Treatment OsCeBip 49 | D12 Treatment OsPR10 50 | E1 CK OSPOX8 51 | E2 CK OsUBQ 52 | E3 CK OsWAK91 53 | E4 CK OsRBBI2 54 | E5 CK OsCeBip 55 | E6 CK OsPR10 56 | E7 Treatment OSPOX8 57 | E8 Treatment OsUBQ 58 | E9 Treatment OsWAK91 59 | E10 Treatment OsRBBI2 60 | E11 Treatment OsCeBip 61 | E12 Treatment OsPR10 62 | F1 CK OSPOX8 63 | F2 CK OsUBQ 64 | F3 CK OsWAK91 65 | F4 CK OsRBBI2 66 | F5 CK OsCeBip 67 | F6 CK OsPR10 68 | F7 Treatment OSPOX8 69 | F8 Treatment OsUBQ 70 | F9 Treatment OsWAK91 71 | F10 Treatment OsRBBI2 72 | F11 Treatment OsCeBip 73 | F12 Treatment OsPR10 74 | G1 CK OSPOX8 75 | G2 CK OsUBQ 76 | G3 CK OsWAK91 77 | G4 CK OsRBBI2 78 | G5 CK OsCeBip 79 | G6 CK OsPR10 80 | G7 Treatment OSPOX8 81 | G8 Treatment OsUBQ 82 | G9 Treatment OsWAK91 83 | G10 Treatment OsRBBI2 84 | G11 Treatment OsCeBip 85 | G12 Treatment OsPR10 86 | H1 CK OSPOX8 87 | H2 CK OsUBQ 88 | H3 CK OsWAK91 89 | H4 CK OsRBBI2 90 | H5 CK OsCeBip 91 | H6 CK OsPR10 92 | H7 Treatment OSPOX8 93 | H8 Treatment OsUBQ 94 | H9 Treatment OsWAK91 95 | H10 Treatment OsRBBI2 96 | H11 Treatment OsCeBip 97 | H12 Treatment OsPR10 98 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/R/CalRTable.R: -------------------------------------------------------------------------------- 1 | #' @name CalRTable 2 | #' @author Xiang LI 3 | #' @title Calculate RNA volume for reverse transcription. 4 | #' @description The first step of qPCR is usually the preparation of cDNA. 5 | #' We need to calculate the column of RNA for reverse transcription to cDNA. 6 | #' So, if we have the concentration of RNA, we can use the function `CalRTable` to do that. 7 | #' 8 | #' @param data A data.frame contained the sample names and the concentration value. The default unit of concentration is ng/uL. 9 | #' @param template A data.frame contained the information of reverse transcription. In this data.frame there must be a column called `all`. 10 | #' @param RNA.weight RNA weight required for reverse transcription. Default is 1 ug. 11 | #' 12 | #' @importFrom dplyr select rename group_by mutate ungroup 13 | #' @importFrom magrittr %>% 14 | #' 15 | #' @export 16 | #' 17 | #' @examples 18 | #' df.1.path <- system.file("examples", "crtv.data.txt", package = "qPCRtools") 19 | #' df.2.path <- system.file("examples", "crtv.template.txt", package = "qPCRtools") 20 | #' df.1 <- read.table(df.1.path, sep = "\t", header = TRUE) 21 | #' df.2 <- read.table(df.2.path, sep = "\t", header = TRUE) 22 | #' result <- CalRTable(data = df.1, template = df.2, RNA.weight = 2) 23 | #' head(result) 24 | #' @return A list contain a table and a figure. 25 | globalVariables(c("data", "template", "RNA.weight", 26 | "df.1", "sum.temp", "sample", 27 | "concentration", "volume.RNA", 28 | "mean","volume.h2o","all", 29 | "sum.temp","volume.RNA", 30 | "df.2")) 31 | CalRTable <- function(data, template, RNA.weight = 1) { 32 | df.1 <- template * RNA.weight 33 | 34 | sum.temp <- rowSums(df.1[1, ]) - df.1$all 35 | 36 | df.2 <- data %>% 37 | dplyr::group_by(sample) %>% 38 | dplyr::summarise(mean = mean(concentration)) %>% 39 | dplyr::ungroup() %>% 40 | dplyr::mutate(volume.RNA = RNA.weight / mean * 1000) %>% 41 | cbind(df.1) %>% 42 | dplyr::mutate(volume.h2o = all - sum.temp - volume.RNA) 43 | return(df.2) 44 | } 45 | 46 | 47 | -------------------------------------------------------------------------------- /development.record.R: -------------------------------------------------------------------------------- 1 | # create description 2 | golem::fill_desc( 3 | pkg_name = "qPCRtools", # The Name of the package containing the App 4 | pkg_title = "Tools for qPCR", # The Title of the package containing the App 5 | pkg_description = "PKG_DESC.", # The Description of the package containing the App 6 | author_first_name = "Xiang", # Your First Name 7 | author_last_name = "LI", # Your Last Name 8 | author_email = "lixiang117423@gmail.com", # Your Email 9 | repo_url = "https://github.com/lixiang117423/qPCRtools" # The URL of the GitHub Repo (optional) 10 | ) 11 | 12 | # use license 13 | usethis::use_mit_license( "Xiang LI" ) 14 | 15 | # insert packages 16 | usethis::use_package("dplyr") 17 | usethis::use_package("magrittr") 18 | usethis::use_package("ggplot2") 19 | usethis::use_package("ggpmisc") 20 | # usethis::use_package("stringr") 21 | # usethis::use_package("data.table") 22 | usethis::use_package("multcomp") 23 | usethis::use_package("broom") 24 | # usethis::use_package("readxl") 25 | # usethis::use_package("reshape2") 26 | # usethis::use_package("xlsx") 27 | # usethis::use_package("sjmisc") 28 | usethis::use_package("kableExtra") 29 | usethis::use_package("stats") 30 | usethis::use_package('ggthemes') 31 | usethis::use_package('rstatix') 32 | usethis::use_package('tibble') 33 | usethis::use_package('tidyr') 34 | 35 | # other 36 | usethis::use_lifecycle_badge( "Experimental" ) 37 | # 版本号,DESCRIPTION文件发生变化 38 | usethis::use_version("major") 39 | usethis::use_version("minor") 40 | usethis::use_version("patch") 41 | 42 | 43 | # create functions 44 | # golem::add_module("test") 45 | 46 | # copy files 47 | file.copy("./inst/", "./CRAN/qPCRtools/", recursive = TRUE) 48 | file.copy("./man/", "./CRAN/qPCRtools/", recursive = TRUE) 49 | file.copy("./DESCRIPTION", "./CRAN/qPCRtools/", recursive = TRUE) 50 | file.copy("./R/", "./CRAN/qPCRtools/", recursive = TRUE) 51 | file.copy("./LICENSE", "./CRAN/qPCRtools/", recursive = TRUE) 52 | 53 | # check and build 54 | library(roxygen2) 55 | 56 | rm(list = ls()) 57 | 58 | roxygen2::roxygenize('./CRAN/qPCRtools') 59 | 60 | system('R CMD build ./CRAN/qPCRtools --binary') 61 | 62 | system('R CMD check qPCRtools_1.0.1.tar.gz --as-cran') 63 | 64 | # devtools::install_local('ggmotif_0.1.3.tar.gz') 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/ddct.design.txt: -------------------------------------------------------------------------------- 1 | Position Group Gene BioRep 2 | A1 CK OSPOX8 1 3 | A2 CK OsUBQ 1 4 | A3 CK OsWAK91 1 5 | A4 CK OsRBBI2 1 6 | A5 CK OsCeBip 1 7 | A6 CK OsPR10 1 8 | A7 Treatment OSPOX8 1 9 | A8 Treatment OsUBQ 1 10 | A9 Treatment OsWAK91 1 11 | A10 Treatment OsRBBI2 1 12 | A11 Treatment OsCeBip 1 13 | A12 Treatment OsPR10 1 14 | B1 CK OSPOX8 1 15 | B2 CK OsUBQ 1 16 | B3 CK OsWAK91 1 17 | B4 CK OsRBBI2 1 18 | B5 CK OsCeBip 1 19 | B6 CK OsPR10 1 20 | B7 Treatment OSPOX8 1 21 | B8 Treatment OsUBQ 1 22 | B9 Treatment OsWAK91 1 23 | B10 Treatment OsRBBI2 1 24 | B11 Treatment OsCeBip 1 25 | B12 Treatment OsPR10 1 26 | C1 CK OSPOX8 2 27 | C2 CK OsUBQ 2 28 | C3 CK OsWAK91 2 29 | C4 CK OsRBBI2 2 30 | C5 CK OsCeBip 2 31 | C6 CK OsPR10 2 32 | C7 Treatment OSPOX8 2 33 | C8 Treatment OsUBQ 2 34 | C9 Treatment OsWAK91 2 35 | C10 Treatment OsRBBI2 2 36 | C11 Treatment OsCeBip 2 37 | C12 Treatment OsPR10 2 38 | D1 CK OSPOX8 2 39 | D2 CK OsUBQ 2 40 | D3 CK OsWAK91 2 41 | D4 CK OsRBBI2 2 42 | D5 CK OsCeBip 2 43 | D6 CK OsPR10 2 44 | D7 Treatment OSPOX8 2 45 | D8 Treatment OsUBQ 2 46 | D9 Treatment OsWAK91 2 47 | D10 Treatment OsRBBI2 2 48 | D11 Treatment OsCeBip 2 49 | D12 Treatment OsPR10 2 50 | E1 CK OSPOX8 3 51 | E2 CK OsUBQ 3 52 | E3 CK OsWAK91 3 53 | E4 CK OsRBBI2 3 54 | E5 CK OsCeBip 3 55 | E6 CK OsPR10 3 56 | E7 Treatment OSPOX8 3 57 | E8 Treatment OsUBQ 3 58 | E9 Treatment OsWAK91 3 59 | E10 Treatment OsRBBI2 3 60 | E11 Treatment OsCeBip 3 61 | E12 Treatment OsPR10 3 62 | F1 CK OSPOX8 3 63 | F2 CK OsUBQ 3 64 | F3 CK OsWAK91 3 65 | F4 CK OsRBBI2 3 66 | F5 CK OsCeBip 3 67 | F6 CK OsPR10 3 68 | F7 Treatment OSPOX8 3 69 | F8 Treatment OsUBQ 3 70 | F9 Treatment OsWAK91 3 71 | F10 Treatment OsRBBI2 3 72 | F11 Treatment OsCeBip 3 73 | F12 Treatment OsPR10 3 74 | G1 CK OSPOX8 4 75 | G2 CK OsUBQ 4 76 | G3 CK OsWAK91 4 77 | G4 CK OsRBBI2 4 78 | G5 CK OsCeBip 4 79 | G6 CK OsPR10 4 80 | G7 Treatment OSPOX8 4 81 | G8 Treatment OsUBQ 4 82 | G9 Treatment OsWAK91 4 83 | G10 Treatment OsRBBI2 4 84 | G11 Treatment OsCeBip 4 85 | G12 Treatment OsPR10 4 86 | H1 CK OSPOX8 4 87 | H2 CK OsUBQ 4 88 | H3 CK OsWAK91 4 89 | H4 CK OsRBBI2 4 90 | H5 CK OsCeBip 4 91 | H6 CK OsPR10 4 92 | H7 Treatment OSPOX8 4 93 | H8 Treatment OsUBQ 4 94 | H9 Treatment OsWAK91 4 95 | H10 Treatment OsRBBI2 4 96 | H11 Treatment OsCeBip 4 97 | H12 Treatment OsPR10 4 98 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/cal.expre.rqpcr.design.txt: -------------------------------------------------------------------------------- 1 | Position Group Gene BioRep TechRep Eff 2 | A1 CK OSPOX8 1 1 1.96 3 | A2 CK OsUBQ 1 1 1.77 4 | A3 CK OsWAK91 1 1 2.2 5 | A4 CK OsRBBI2 1 1 1.93 6 | A5 CK OsCeBip 1 1 1.83 7 | A6 CK OsPR10 1 1 1.87 8 | A7 Treatment OSPOX8 1 1 1.96 9 | A8 Treatment OsUBQ 1 1 1.77 10 | A9 Treatment OsWAK91 1 1 2.2 11 | A10 Treatment OsRBBI2 1 1 1.93 12 | A11 Treatment OsCeBip 1 1 1.83 13 | A12 Treatment OsPR10 1 1 1.87 14 | B1 CK OSPOX8 1 2 1.96 15 | B2 CK OsUBQ 1 2 1.77 16 | B3 CK OsWAK91 1 2 2.2 17 | B4 CK OsRBBI2 1 2 1.93 18 | B5 CK OsCeBip 1 2 1.83 19 | B6 CK OsPR10 1 2 1.87 20 | B7 Treatment OSPOX8 1 2 1.96 21 | B8 Treatment OsUBQ 1 2 1.77 22 | B9 Treatment OsWAK91 1 2 2.2 23 | B10 Treatment OsRBBI2 1 2 1.93 24 | B11 Treatment OsCeBip 1 2 1.83 25 | B12 Treatment OsPR10 1 2 1.87 26 | C1 CK OSPOX8 2 1 1.96 27 | C2 CK OsUBQ 2 1 1.77 28 | C3 CK OsWAK91 2 1 2.2 29 | C4 CK OsRBBI2 2 1 1.93 30 | C5 CK OsCeBip 2 1 1.83 31 | C6 CK OsPR10 2 1 1.87 32 | C7 Treatment OSPOX8 2 1 1.96 33 | C8 Treatment OsUBQ 2 1 1.77 34 | C9 Treatment OsWAK91 2 1 2.2 35 | C10 Treatment OsRBBI2 2 1 1.93 36 | C11 Treatment OsCeBip 2 1 1.83 37 | C12 Treatment OsPR10 2 1 1.87 38 | D1 CK OSPOX8 2 2 1.96 39 | D2 CK OsUBQ 2 2 1.77 40 | D3 CK OsWAK91 2 2 2.2 41 | D4 CK OsRBBI2 2 2 1.93 42 | D5 CK OsCeBip 2 2 1.83 43 | D6 CK OsPR10 2 2 1.87 44 | D7 Treatment OSPOX8 2 2 1.96 45 | D8 Treatment OsUBQ 2 2 1.77 46 | D9 Treatment OsWAK91 2 2 2.2 47 | D10 Treatment OsRBBI2 2 2 1.93 48 | D11 Treatment OsCeBip 2 2 1.83 49 | D12 Treatment OsPR10 2 2 1.87 50 | E1 CK OSPOX8 3 1 1.96 51 | E2 CK OsUBQ 3 1 1.77 52 | E3 CK OsWAK91 3 1 2.2 53 | E4 CK OsRBBI2 3 1 1.93 54 | E5 CK OsCeBip 3 1 1.83 55 | E6 CK OsPR10 3 1 1.87 56 | E7 Treatment OSPOX8 3 1 1.96 57 | E8 Treatment OsUBQ 3 1 1.77 58 | E9 Treatment OsWAK91 3 1 2.2 59 | E10 Treatment OsRBBI2 3 1 1.93 60 | E11 Treatment OsCeBip 3 1 1.83 61 | E12 Treatment OsPR10 3 1 1.87 62 | F1 CK OSPOX8 3 2 1.96 63 | F2 CK OsUBQ 3 2 1.77 64 | F3 CK OsWAK91 3 2 2.2 65 | F4 CK OsRBBI2 3 2 1.93 66 | F5 CK OsCeBip 3 2 1.83 67 | F6 CK OsPR10 3 2 1.87 68 | F7 Treatment OSPOX8 3 2 1.96 69 | F8 Treatment OsUBQ 3 2 1.77 70 | F9 Treatment OsWAK91 3 2 2.2 71 | F10 Treatment OsRBBI2 3 2 1.93 72 | F11 Treatment OsCeBip 3 2 1.83 73 | F12 Treatment OsPR10 3 2 1.87 74 | G1 CK OSPOX8 4 1 1.96 75 | G2 CK OsUBQ 4 1 1.77 76 | G3 CK OsWAK91 4 1 2.2 77 | G4 CK OsRBBI2 4 1 1.93 78 | G5 CK OsCeBip 4 1 1.83 79 | G6 CK OsPR10 4 1 1.87 80 | G7 Treatment OSPOX8 4 1 1.96 81 | G8 Treatment OsUBQ 4 1 1.77 82 | G9 Treatment OsWAK91 4 1 2.2 83 | G10 Treatment OsRBBI2 4 1 1.93 84 | G11 Treatment OsCeBip 4 1 1.83 85 | G12 Treatment OsPR10 4 1 1.87 86 | H1 CK OSPOX8 4 2 1.96 87 | H2 CK OsUBQ 4 2 1.77 88 | H3 CK OsWAK91 4 2 2.2 89 | H4 CK OsRBBI2 4 2 1.93 90 | H5 CK OsCeBip 4 2 1.83 91 | H6 CK OsPR10 4 2 1.87 92 | H7 Treatment OSPOX8 4 2 1.96 93 | H8 Treatment OsUBQ 4 2 1.77 94 | H9 Treatment OsWAK91 4 2 2.2 95 | H10 Treatment OsRBBI2 4 2 1.93 96 | H11 Treatment OsCeBip 4 2 1.83 97 | H12 Treatment OsPR10 4 2 1.87 98 | -------------------------------------------------------------------------------- /R/CalExp2dCt.R: -------------------------------------------------------------------------------- 1 | #' @name CalExp2dCt 2 | #' @author Xiang LI 3 | #' 4 | #' @title Calculate expression using standard curve. 5 | #' @description Calculate expression using standard curve. 6 | #' 7 | #' @param cq.table The data frame of the position and cq value. 8 | #' @param design.table The data frame of the position and corresponding information. 9 | #' @param ref.gene The name of reference gene. 10 | #' 11 | #' @export 12 | #' @return A list contain a table and a figure. 13 | #' @examples 14 | #' df1.path <- system.file("examples", "dct.cq.txt", package = "qPCRtools") 15 | #' df2.path <- system.file("examples", "dct.design.txt", package = "qPCRtools") 16 | #' cq.table <- read.table(df1.path, sep = ",", header = TRUE) 17 | #' design.table <- read.table(df2.path, sep = ",", header = TRUE) 18 | #' CalExp2dCt(cq.table, 19 | #' design.table, 20 | #' ref.gene = "Actin" 21 | #' ) -> res 22 | #' 23 | globalVariables(c( 24 | "cq.table", 25 | "curve.table", 26 | "design.table", 27 | "correction", 28 | "ref.gene", 29 | "stat.method", 30 | "ref.group", 31 | "fig.type", 32 | "fig.ncol", 33 | "out", 34 | "cq", 35 | "max.cq", 36 | "min.cq", 37 | "expre", 38 | "Intercept", 39 | "Slope", 40 | "Treatment", 41 | "element_text", 42 | "group2", 43 | "max.temp", 44 | "mean.expre", 45 | "mean.ref", 46 | "n", 47 | "sd", 48 | "sd.expre", 49 | "Treatment", 50 | "mean.ref", 51 | "group2", 52 | "temp", 53 | "n", 54 | "sd.expre", 55 | "n", 56 | "mean.expre", 57 | "element_text", 58 | "max.temp", 59 | "gene", 60 | "group", 61 | "biorep", 62 | "Target", 63 | "Reference", 64 | "ddct1", 65 | "mean.expression", 66 | "n.biorep", 67 | "sd.expression", 68 | "se.expression", 69 | "Reference", 70 | "Target", 71 | "biorep", 72 | "ddct1", 73 | "gene", 74 | "group", 75 | "mean.expression", 76 | "n.biorep", 77 | "sd.expression", 78 | "se.expression", 79 | "BioRep", 80 | "Eff", 81 | "Group", 82 | "TechRep" 83 | )) 84 | CalExp2dCt <- function(cq.table, 85 | design.table, 86 | ref.gene = "Actin") { 87 | # merge data 88 | cq.table %>% 89 | dplyr::left_join(design.table, by = "Position") %>% 90 | dplyr::rename( 91 | position = Position, 92 | cq = Cq, 93 | group = Group, 94 | gene = Gene, 95 | biorep = BioRep 96 | ) -> df 97 | 98 | # reference gene 99 | df %>% 100 | dplyr::filter(gene == ref.gene) %>% 101 | dplyr::group_by(group, biorep) %>% 102 | dplyr::mutate( 103 | mean.cq = mean(cq), 104 | temp = paste0(group, biorep) 105 | ) %>% 106 | dplyr::ungroup() %>% 107 | dplyr::select(temp, mean.cq) %>% 108 | dplyr::distinct_all() -> df.ref 109 | 110 | # target gene 111 | df %>% 112 | dplyr::filter(gene != ref.gene) %>% 113 | dplyr::mutate(temp = paste0(group, biorep)) %>% 114 | dplyr::left_join(df.ref, by = "temp") %>% 115 | dplyr::select(-temp) %>% 116 | dplyr::mutate(expre = 2^(mean.cq - cq)) %>% 117 | dplyr::group_by(group, gene) %>% 118 | dplyr::mutate( 119 | n = dplyr::n(), 120 | mean.expre = mean(expre), 121 | sd.expre = sd(expre), 122 | se.expre = sd.expre / sqrt(n) 123 | ) %>% 124 | dplyr::ungroup() -> res 125 | 126 | return(res) 127 | } 128 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/R/CalExp2dCt.R: -------------------------------------------------------------------------------- 1 | #' @name CalExp2dCt 2 | #' @author Xiang LI 3 | #' 4 | #' @title Calculate expression using standard curve. 5 | #' @description Calculate expression using standard curve. 6 | #' 7 | #' @param cq.table The data frame of the position and cq value. 8 | #' @param design.table The data frame of the position and corresponding information. 9 | #' @param ref.gene The name of reference gene. 10 | #' 11 | #' @export 12 | #' @return A list contain a table and a figure. 13 | #' @examples 14 | #' df1.path <- system.file("examples", "dct.cq.txt", package = "qPCRtools") 15 | #' df2.path <- system.file("examples", "dct.design.txt", package = "qPCRtools") 16 | #' cq.table <- read.table(df1.path, sep = ",", header = TRUE) 17 | #' design.table <- read.table(df2.path, sep = ",", header = TRUE) 18 | #' CalExp2dCt(cq.table, 19 | #' design.table, 20 | #' ref.gene = "Actin" 21 | #' ) -> res 22 | #' 23 | globalVariables(c( 24 | "cq.table", 25 | "curve.table", 26 | "design.table", 27 | "correction", 28 | "ref.gene", 29 | "stat.method", 30 | "ref.group", 31 | "fig.type", 32 | "fig.ncol", 33 | "out", 34 | "cq", 35 | "max.cq", 36 | "min.cq", 37 | "expre", 38 | "Intercept", 39 | "Slope", 40 | "Treatment", 41 | "element_text", 42 | "group2", 43 | "max.temp", 44 | "mean.expre", 45 | "mean.ref", 46 | "n", 47 | "sd", 48 | "sd.expre", 49 | "Treatment", 50 | "mean.ref", 51 | "group2", 52 | "temp", 53 | "n", 54 | "sd.expre", 55 | "n", 56 | "mean.expre", 57 | "element_text", 58 | "max.temp", 59 | "gene", 60 | "group", 61 | "biorep", 62 | "Target", 63 | "Reference", 64 | "ddct1", 65 | "mean.expression", 66 | "n.biorep", 67 | "sd.expression", 68 | "se.expression", 69 | "Reference", 70 | "Target", 71 | "biorep", 72 | "ddct1", 73 | "gene", 74 | "group", 75 | "mean.expression", 76 | "n.biorep", 77 | "sd.expression", 78 | "se.expression", 79 | "BioRep", 80 | "Eff", 81 | "Group", 82 | "TechRep" 83 | )) 84 | CalExp2dCt <- function(cq.table, 85 | design.table, 86 | ref.gene = "Actin") { 87 | # merge data 88 | cq.table %>% 89 | dplyr::left_join(design.table, by = "Position") %>% 90 | dplyr::rename( 91 | position = Position, 92 | cq = Cq, 93 | group = Group, 94 | gene = Gene, 95 | biorep = BioRep 96 | ) -> df 97 | 98 | # reference gene 99 | df %>% 100 | dplyr::filter(gene == ref.gene) %>% 101 | dplyr::group_by(group, biorep) %>% 102 | dplyr::mutate( 103 | mean.cq = mean(cq), 104 | temp = paste0(group, biorep) 105 | ) %>% 106 | dplyr::ungroup() %>% 107 | dplyr::select(temp, mean.cq) %>% 108 | dplyr::distinct_all() -> df.ref 109 | 110 | # target gene 111 | df %>% 112 | dplyr::filter(gene != ref.gene) %>% 113 | dplyr::mutate(temp = paste0(group, biorep)) %>% 114 | dplyr::left_join(df.ref, by = "temp") %>% 115 | dplyr::select(-temp) %>% 116 | dplyr::mutate(expre = 2^(mean.cq - cq)) %>% 117 | dplyr::group_by(group, gene) %>% 118 | dplyr::mutate( 119 | n = dplyr::n(), 120 | mean.expre = mean(expre), 121 | sd.expre = sd(expre), 122 | se.expre = sd.expre / sqrt(n) 123 | ) %>% 124 | dplyr::ungroup() -> res 125 | 126 | return(res) 127 | } 128 | -------------------------------------------------------------------------------- /R/CalCurve.R: -------------------------------------------------------------------------------- 1 | #' @name CalCurve 2 | #' @author Xiang LI 3 | #' @title Standard Curve Calculation. 4 | #' @description The function can calculate the standard curve. 5 | #' At the same time, it can get the amplification efficiency of primer(s). 6 | #' Based on the amplification efficiency, we can know which method can be 7 | #' used to calculate the expression level. 8 | #' 9 | #' @param cq.table The data frame of the position and Cq value. 10 | #' @param concen.table The data frame of the position and concentration. 11 | #' @param highest.concen The highest concentration for calculation. 12 | #' @param lowest.concen The lowest concentration for calculation. 13 | #' @param dilution Dilution factor of cDNA template. The default value is 4. 14 | #' @param by.mean Calculation by mean Cq value or not. The default value is TRUE. 15 | #' 16 | #' @importFrom dplyr left_join filter group_by mutate ungroup 17 | #' @importFrom stats lm 18 | #' @importFrom broom glance 19 | #' @importFrom ggplot2 ggplot aes geom_point geom_smooth labs theme_bw 20 | #' @importFrom ggpmisc stat_poly_eq 21 | #' @importFrom kableExtra kable_styling kable 22 | #' 23 | #' @export 24 | #' 25 | #' @examples 26 | #' df.1.path <- system.file("examples", "calsc.cq.txt", package = "qPCRtools") 27 | #' df.2.path <- system.file("examples", "calsc.info.txt", package = "qPCRtools") 28 | #' df.1 <- read.table(df.1.path, header = TRUE) 29 | #' df.2 <- read.table(df.2.path, header = TRUE) 30 | #' CalCurve( 31 | #' cq.table = df.1, 32 | #' concen.table = df.2, 33 | #' lowest.concen = 4, 34 | #' highest.concen = 4096, 35 | #' dilu = 4, 36 | #' by = "mean" 37 | #' ) -> p 38 | #' 39 | #' p[["table"]] 40 | #' p[["figure"]] 41 | #' @return A list. 42 | globalVariables(c( 43 | "cq.table", 44 | "concen.table", 45 | "highest.concen", 46 | "lowest.concen", 47 | "dilution", 48 | "by.mean", 49 | "Conc", 50 | "Gene", 51 | "Cq", 52 | "Formula", 53 | "Slope", 54 | "Intercept", 55 | "R2", 56 | "P.value", 57 | "max.Cq", 58 | "min.Cq", 59 | "E", 60 | "Date", 61 | "..rr.label..", 62 | "..p.value.label..", 63 | "mean.cq" 64 | )) 65 | 66 | CalCurve <- function(cq.table, 67 | concen.table, 68 | highest.concen, 69 | lowest.concen, 70 | dilution = 4, 71 | by.mean = TRUE) { 72 | cq.table %>% 73 | dplyr::left_join(concen.table, by = "Position") %>% 74 | dplyr::filter(Conc >= lowest.concen & Conc <= highest.concen) %>% 75 | dplyr::group_by(Gene, Conc) %>% 76 | dplyr::mutate( 77 | mean.cq = mean(Cq), 78 | Conc = log(Conc, base = dilution) 79 | ) %>% 80 | dplyr::ungroup() %>% 81 | dplyr::group_by(Gene) %>% 82 | dplyr::mutate( 83 | max.Cq = max(Cq), 84 | min.Cq = min(Cq) 85 | ) %>% 86 | dplyr::ungroup() -> df 87 | 88 | if (isTRUE(by.mean)) { 89 | # build model 90 | fit.res <- NULL 91 | 92 | for (i in unique(df$Gene)) { 93 | df.sub <- df %>% 94 | dplyr::filter(Gene == i) 95 | 96 | fit <- stats::lm(mean.cq ~ Conc, data = df.sub) 97 | intercept <- fit[["coefficients"]][["(Intercept)"]] %>% 98 | round(2) 99 | slope <- fit[["coefficients"]][["Conc"]] %>% 100 | round(2) 101 | 102 | formula <- paste0("y = ", slope, "*Conc", " + ", intercept) 103 | 104 | r.2 <- broom::glance(fit)[1, 1] %>% 105 | round(4) %>% 106 | as.numeric() 107 | 108 | p.value <- broom::glance(fit)[1, 5] %>% 109 | round(5) %>% 110 | as.numeric() 111 | 112 | df.temp <- data.frame( 113 | Gene = i, 114 | Formula = formula, 115 | Slope = slope, 116 | Intercept = intercept, 117 | R2 = r.2, 118 | P.value = p.value, 119 | max.Cq = unique(df.sub$max.Cq), 120 | min.Cq = unique(df.sub$min.Cq), 121 | E = round(dilution^(-1 / slope) - 1, 3), 122 | Date = as.character(Sys.Date()) 123 | ) 124 | fit.res <- rbind(fit.res, df.temp) -> res.table 125 | } 126 | 127 | ggplot2::ggplot(df, ggplot2::aes(Conc, mean.cq, color = Gene)) + 128 | ggplot2::geom_point() + 129 | ggplot2::geom_smooth(method = "lm", show.legend = FALSE) + 130 | ggpmisc::stat_poly_eq( 131 | ggplot2::aes( 132 | label = paste( # ..eq.label.., 133 | # ..rr.label.., 134 | ggplot2::after_stat(rr.label), 135 | ggplot2::after_stat(p.value.label), 136 | # ..p.value.label.., 137 | sep = "~~~~" 138 | ) 139 | ), 140 | show.legend = FALSE, 141 | formula = y ~ x, 142 | parse = T, 143 | rr.digits = 5, 144 | coef.digits = 3, 145 | label.x = c(0.05), 146 | label.y = seq( 147 | 0.05, 148 | 0.06 * (length(unique(df$Gene)) + 1), 149 | 0.06 150 | ) 151 | ) + 152 | ggplot2::labs( 153 | x = "log Relative Concentration", 154 | y = "Mean Cq Value" 155 | ) + 156 | ggplot2::theme_bw() -> p 157 | 158 | res <- list(table = res.table, figure = p) 159 | } else { 160 | # build model 161 | fit.res <- NULL 162 | 163 | for (i in unique(df$Gene)) { 164 | df.sub <- df %>% 165 | dplyr::filter(Gene == i) 166 | 167 | fit <- stats::lm(Cq ~ Conc, data = df.sub) 168 | intercept <- fit[["coefficients"]][["(Intercept)"]] %>% 169 | round(2) 170 | slope <- fit[["coefficients"]][["Conc"]] %>% 171 | round(2) 172 | 173 | formula <- paste0("y = ", slope, "*Conc", " + ", intercept) 174 | 175 | r.2 <- broom::glance(fit)[1, 1] %>% 176 | round(4) %>% 177 | as.numeric() 178 | 179 | p.value <- broom::glance(fit)[1, 5] %>% 180 | round(5) %>% 181 | as.numeric() 182 | 183 | df.temp <- data.frame( 184 | Gene = i, 185 | Formula = formula, 186 | Slope = slope, 187 | Intercept = intercept, 188 | R2 = r.2, 189 | P.value = p.value, 190 | max.Cq = unique(df.sub$max.Cq), 191 | min.Cq = unique(df.sub$min.Cq), 192 | E = round(dilution^(-1 / slope) - 1, 3), 193 | Date = as.character(Sys.Date()) 194 | ) 195 | fit.res <- rbind(fit.res, df.temp) -> res.table 196 | } 197 | 198 | ggplot2::ggplot(df, ggplot2::aes(Conc, Cq, color = Gene)) + 199 | ggplot2::geom_point() + 200 | ggplot2::geom_smooth(method = "lm", show.legend = FALSE) + 201 | ggpmisc::stat_poly_eq( 202 | ggplot2::aes( 203 | label = paste( # ..eq.label.., 204 | ..rr.label.., 205 | ..p.value.label.., 206 | sep = "~~~~" 207 | ) 208 | ), 209 | show.legend = FALSE, 210 | formula = y ~ x, 211 | parse = T, 212 | rr.digits = 5, 213 | coef.digits = 3, 214 | label.x = c(0.05), 215 | label.y = seq( 216 | 0.05, 217 | 0.06 * (length(unique(df$Gene)) + 1), 218 | 0.06 219 | ) 220 | ) + 221 | ggplot2::labs( 222 | x = "log Relative Concentration", 223 | y = "Cq Value" 224 | ) + 225 | ggplot2::theme_bw() -> p 226 | 227 | res <- list(table = res.table, figure = p) 228 | } 229 | return(res) 230 | } 231 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/R/CalCurve.R: -------------------------------------------------------------------------------- 1 | #' @name CalCurve 2 | #' @author Xiang LI 3 | #' @title Standard Curve Calculation. 4 | #' @description The function can calculate the standard curve. 5 | #' At the same time, it can get the amplification efficiency of primer(s). 6 | #' Based on the amplification efficiency, we can know which method can be 7 | #' used to calculate the expression level. 8 | #' 9 | #' @param cq.table The data frame of the position and Cq value. 10 | #' @param concen.table The data frame of the position and concentration. 11 | #' @param highest.concen The highest concentration for calculation. 12 | #' @param lowest.concen The lowest concentration for calculation. 13 | #' @param dilution Dilution factor of cDNA template. The default value is 4. 14 | #' @param by.mean Calculation by mean Cq value or not. The default value is TRUE. 15 | #' 16 | #' @importFrom dplyr left_join filter group_by mutate ungroup 17 | #' @importFrom stats lm 18 | #' @importFrom broom glance 19 | #' @importFrom ggplot2 ggplot aes geom_point geom_smooth labs theme_bw 20 | #' @importFrom ggpmisc stat_poly_eq 21 | #' @importFrom kableExtra kable_styling kable 22 | #' 23 | #' @export 24 | #' 25 | #' @examples 26 | #' df.1.path <- system.file("examples", "calsc.cq.txt", package = "qPCRtools") 27 | #' df.2.path <- system.file("examples", "calsc.info.txt", package = "qPCRtools") 28 | #' df.1 <- read.table(df.1.path, header = TRUE) 29 | #' df.2 <- read.table(df.2.path, header = TRUE) 30 | #' CalCurve( 31 | #' cq.table = df.1, 32 | #' concen.table = df.2, 33 | #' lowest.concen = 4, 34 | #' highest.concen = 4096, 35 | #' dilu = 4, 36 | #' by = "mean" 37 | #' ) -> p 38 | #' 39 | #' p[["table"]] 40 | #' p[["figure"]] 41 | #' @return A list. 42 | globalVariables(c( 43 | "cq.table", 44 | "concen.table", 45 | "highest.concen", 46 | "lowest.concen", 47 | "dilution", 48 | "by.mean", 49 | "Conc", 50 | "Gene", 51 | "Cq", 52 | "Formula", 53 | "Slope", 54 | "Intercept", 55 | "R2", 56 | "P.value", 57 | "max.Cq", 58 | "min.Cq", 59 | "E", 60 | "Date", 61 | "..rr.label..", 62 | "..p.value.label..", 63 | "mean.cq" 64 | )) 65 | 66 | CalCurve <- function(cq.table, 67 | concen.table, 68 | highest.concen, 69 | lowest.concen, 70 | dilution = 4, 71 | by.mean = TRUE) { 72 | cq.table %>% 73 | dplyr::left_join(concen.table, by = "Position") %>% 74 | dplyr::filter(Conc >= lowest.concen & Conc <= highest.concen) %>% 75 | dplyr::group_by(Gene, Conc) %>% 76 | dplyr::mutate( 77 | mean.cq = mean(Cq), 78 | Conc = log(Conc, base = dilution) 79 | ) %>% 80 | dplyr::ungroup() %>% 81 | dplyr::group_by(Gene) %>% 82 | dplyr::mutate( 83 | max.Cq = max(Cq), 84 | min.Cq = min(Cq) 85 | ) %>% 86 | dplyr::ungroup() -> df 87 | 88 | if (isTRUE(by.mean)) { 89 | # build model 90 | fit.res <- NULL 91 | 92 | for (i in unique(df$Gene)) { 93 | df.sub <- df %>% 94 | dplyr::filter(Gene == i) 95 | 96 | fit <- stats::lm(mean.cq ~ Conc, data = df.sub) 97 | intercept <- fit[["coefficients"]][["(Intercept)"]] %>% 98 | round(2) 99 | slope <- fit[["coefficients"]][["Conc"]] %>% 100 | round(2) 101 | 102 | formula <- paste0("y = ", slope, "*Conc", " + ", intercept) 103 | 104 | r.2 <- broom::glance(fit)[1, 1] %>% 105 | round(4) %>% 106 | as.numeric() 107 | 108 | p.value <- broom::glance(fit)[1, 5] %>% 109 | round(5) %>% 110 | as.numeric() 111 | 112 | df.temp <- data.frame( 113 | Gene = i, 114 | Formula = formula, 115 | Slope = slope, 116 | Intercept = intercept, 117 | R2 = r.2, 118 | P.value = p.value, 119 | max.Cq = unique(df.sub$max.Cq), 120 | min.Cq = unique(df.sub$min.Cq), 121 | E = round(dilution^(-1 / slope) - 1, 3), 122 | Date = as.character(Sys.Date()) 123 | ) 124 | fit.res <- rbind(fit.res, df.temp) -> res.table 125 | } 126 | 127 | ggplot2::ggplot(df, ggplot2::aes(Conc, mean.cq, color = Gene)) + 128 | ggplot2::geom_point() + 129 | ggplot2::geom_smooth(method = "lm", show.legend = FALSE) + 130 | ggpmisc::stat_poly_eq( 131 | ggplot2::aes( 132 | label = paste( # ..eq.label.., 133 | # ..rr.label.., 134 | ggplot2::after_stat(rr.label), 135 | ggplot2::after_stat(p.value.label), 136 | # ..p.value.label.., 137 | sep = "~~~~" 138 | ) 139 | ), 140 | show.legend = FALSE, 141 | formula = y ~ x, 142 | parse = T, 143 | rr.digits = 5, 144 | coef.digits = 3, 145 | label.x = c(0.05), 146 | label.y = seq( 147 | 0.05, 148 | 0.06 * (length(unique(df$Gene)) + 1), 149 | 0.06 150 | ) 151 | ) + 152 | ggplot2::labs( 153 | x = "log Relative Concentration", 154 | y = "Mean Cq Value" 155 | ) + 156 | ggplot2::theme_bw() -> p 157 | 158 | res <- list(table = res.table, figure = p) 159 | } else { 160 | # build model 161 | fit.res <- NULL 162 | 163 | for (i in unique(df$Gene)) { 164 | df.sub <- df %>% 165 | dplyr::filter(Gene == i) 166 | 167 | fit <- stats::lm(Cq ~ Conc, data = df.sub) 168 | intercept <- fit[["coefficients"]][["(Intercept)"]] %>% 169 | round(2) 170 | slope <- fit[["coefficients"]][["Conc"]] %>% 171 | round(2) 172 | 173 | formula <- paste0("y = ", slope, "*Conc", " + ", intercept) 174 | 175 | r.2 <- broom::glance(fit)[1, 1] %>% 176 | round(4) %>% 177 | as.numeric() 178 | 179 | p.value <- broom::glance(fit)[1, 5] %>% 180 | round(5) %>% 181 | as.numeric() 182 | 183 | df.temp <- data.frame( 184 | Gene = i, 185 | Formula = formula, 186 | Slope = slope, 187 | Intercept = intercept, 188 | R2 = r.2, 189 | P.value = p.value, 190 | max.Cq = unique(df.sub$max.Cq), 191 | min.Cq = unique(df.sub$min.Cq), 192 | E = round(dilution^(-1 / slope) - 1, 3), 193 | Date = as.character(Sys.Date()) 194 | ) 195 | fit.res <- rbind(fit.res, df.temp) -> res.table 196 | } 197 | 198 | ggplot2::ggplot(df, ggplot2::aes(Conc, Cq, color = Gene)) + 199 | ggplot2::geom_point() + 200 | ggplot2::geom_smooth(method = "lm", show.legend = FALSE) + 201 | ggpmisc::stat_poly_eq( 202 | ggplot2::aes( 203 | label = paste( # ..eq.label.., 204 | ..rr.label.., 205 | ..p.value.label.., 206 | sep = "~~~~" 207 | ) 208 | ), 209 | show.legend = FALSE, 210 | formula = y ~ x, 211 | parse = T, 212 | rr.digits = 5, 213 | coef.digits = 3, 214 | label.x = c(0.05), 215 | label.y = seq( 216 | 0.05, 217 | 0.06 * (length(unique(df$Gene)) + 1), 218 | 0.06 219 | ) 220 | ) + 221 | ggplot2::labs( 222 | x = "log Relative Concentration", 223 | y = "Cq Value" 224 | ) + 225 | ggplot2::theme_bw() -> p 226 | 227 | res <- list(table = res.table, figure = p) 228 | } 229 | return(res) 230 | } 231 | -------------------------------------------------------------------------------- /R/CalExpCurve.R: -------------------------------------------------------------------------------- 1 | #' @name CalExpCurve 2 | #' @author Xiang LI 3 | #' 4 | #' @title Calculate expression using standard curve. 5 | #' @description Calculate expression using standard curve. 6 | #' 7 | #' @param cq.table The data frame of the position and Cq value. 8 | #' @param design.table The data frame of the position and corresponding information. 9 | #' @param correction Correct expression value by reference gene. 10 | #' @param ref.gene The name of reference gene. 11 | #' @param stat.method Statistical method. 12 | #' @param ref.group The name of reference group. 13 | #' @param fig.type Output image type, `box` represents `boxplot`, `bar` represents `barplot`. 14 | #' @param fig.ncol Number of columes of figure. 15 | #' 16 | #' @importFrom dplyr left_join filter group_by mutate ungroup 17 | #' @importFrom stats lm 18 | #' @importFrom broom glance 19 | #' @importFrom ggplot2 ggplot aes geom_point geom_smooth labs theme_bw 20 | #' @importFrom ggpmisc stat_poly_eq 21 | #' 22 | #' @export 23 | #' 24 | #' @return A list contain a table and a figure. 25 | #' 26 | #' @examples 27 | #' df1.path = system.file("examples", "cal.exp.curve.cq.txt", package = "qPCRtools") 28 | #' df2.path = system.file("examples", "cal.expre.curve.sdc.txt", package = "qPCRtools") 29 | #' df3.path = system.file("examples", "cal.exp.curve.design.txt", package = "qPCRtools") 30 | #' 31 | #' cq.table = read.table(df1.path, header = TRUE) 32 | #' curve.table = read.table(df2.path, sep = "\t", header = TRUE) 33 | #' design.table = read.table(df3.path, header = TRUE) 34 | #' 35 | #' CalExpCurve( 36 | #' cq.table, 37 | #' curve.table, 38 | #' design.table, 39 | #' correction = TRUE, 40 | #' ref.gene = "OsUBQ", 41 | #' stat.method = "t.test", 42 | #' ref.group = "CK", 43 | #' fig.type = "box", 44 | #' fig.ncol = NULL) -> res 45 | #' 46 | #' res[["table"]] 47 | #' res[["figure"]] 48 | #' 49 | globalVariables(c( 50 | "cq.table", 51 | "curve.table", 52 | "design.table", 53 | "correction", 54 | "ref.gene", 55 | "stat.method", 56 | "ref.group", 57 | "fig.type", 58 | "fig.ncol", 59 | "out", 60 | "Cq", 61 | "max.Cq", 62 | "min.Cq", 63 | "expre", 64 | "Intercept", 65 | "Slope", 66 | "Treatment", 67 | "element_text", 68 | "group2", 69 | "max.temp", 70 | "mean.expre", 71 | "mean.ref", 72 | "n", 73 | "sd", 74 | "sd.expre", 75 | "Treatment", 76 | "mean.ref", 77 | "group2", 78 | "temp", 79 | "n", 80 | "sd.expre", 81 | "n", 82 | "mean.expre", 83 | "element_text", 84 | "max.temp" 85 | )) 86 | CalExpCurve <- function(cq.table, 87 | curve.table, 88 | design.table, 89 | correction = TRUE, 90 | ref.gene = "OsUBQ", 91 | stat.method = "t.test", 92 | ref.group = "CK", 93 | fig.type = "box", 94 | fig.ncol = NULL) { 95 | # merge data 96 | cq.table %>% 97 | dplyr::left_join(design.table, by = "Position") %>% 98 | dplyr::left_join(curve.table, by = "Gene") %>% 99 | dplyr::mutate(out = dplyr::case_when( 100 | Cq > max.Cq | Cq < min.Cq ~ "yes", 101 | TRUE ~ "no" 102 | )) %>% 103 | dplyr::mutate(expre = (Cq - Intercept) / Slope) -> df 104 | 105 | # print warning message 106 | df.out <- df %>% 107 | dplyr::filter(out == "yes") 108 | if (dim(df.out)[1] != 0) { 109 | warning(paste0("Cq of ", as.character(df.out$Position), " out of curve range!")) 110 | } 111 | 112 | if (isTRUE(correction)) { 113 | df %>% 114 | dplyr::filter(Gene == ref.gene) %>% 115 | dplyr::group_by(Treatment) %>% 116 | dplyr::summarise(mean.ref = mean(expre)) %>% 117 | dplyr::ungroup() %>% 118 | dplyr::left_join(df, by = "Treatment") %>% 119 | dplyr::filter(Gene != ref.gene) %>% 120 | dplyr::mutate(expre = expre / mean.ref) %>% 121 | dplyr::select(Treatment, Gene, expre) -> df 122 | } else { 123 | df %>% 124 | dplyr::select(Treatment, Gene, expre) -> df 125 | } 126 | 127 | # statistics 128 | if (stat.method == "t.test") { 129 | df %>% 130 | dplyr::group_by(Gene) %>% 131 | rstatix::t_test(expre ~ Treatment, ref.group = ref.group) %>% 132 | dplyr::select(Gene, group2, p) %>% 133 | dplyr::mutate(temp = paste0(Gene, group2)) %>% 134 | dplyr::select(temp, p) %>% 135 | dplyr::mutate(signif = dplyr::case_when( 136 | p < 0.001 ~ "***", 137 | p > 0.001 & p < 0.01 ~ "**", 138 | p > 0.01 & p < 0.05 ~ "*", 139 | TRUE ~ "NS" 140 | )) %>% 141 | dplyr::select(temp, signif) -> df.stat 142 | 143 | df %>% 144 | dplyr::mutate(temp = paste0(Gene, Treatment)) %>% 145 | dplyr::left_join(df.stat, by = "temp") -> df 146 | } else if (stat.method == "wilcox.test") { 147 | df %>% 148 | dplyr::group_by(Gene) %>% 149 | rstatix::wilcox_test(expre ~ Treatment, ref.group = ref.group) %>% 150 | dplyr::select(Gene, group2, p) %>% 151 | dplyr::mutate(temp = paste0(Gene, group2)) %>% 152 | dplyr::select(temp, p) %>% 153 | dplyr::mutate(signif = dplyr::case_when( 154 | p < 0.001 ~ "***", 155 | p > 0.001 & p < 0.01 ~ "**", 156 | p > 0.01 & p < 0.05 ~ "*", 157 | TRUE ~ "NS" 158 | )) %>% 159 | dplyr::select(temp, signif) -> df.stat 160 | 161 | df %>% 162 | dplyr::mutate(temp = paste0(Gene, Treatment)) %>% 163 | dplyr::left_join(df.stat, by = "temp") -> df 164 | } else if (stat.method == "anova") { 165 | df.stat <- NULL 166 | for (i in unique(df$Gene)) { 167 | df.sub <- df %>% 168 | dplyr::filter(Gene == i) %>% 169 | dplyr::mutate(Treatment = factor(Treatment)) 170 | fit <- stats::aov(expre ~ Treatment, data = df.sub) 171 | tuk <- multcomp::glht(fit, linfct = multcomp::mcp(Treatment = "Tukey")) 172 | multcomp::cld(tuk, level = 0.95, ddecreasing = TRUE)[["mcletters"]][["Letters"]] %>% 173 | as.data.frame() %>% 174 | dplyr::mutate(Gene = i) %>% 175 | tibble::rownames_to_column(var = "Treatment") %>% 176 | magrittr::set_colnames(c("Treatment", "signif", "Gene")) %>% 177 | dplyr::select(Gene, Treatment, signif) %>% 178 | dplyr::mutate(temp = paste0(Gene, Treatment)) %>% 179 | dplyr::select(temp, signif) %>% 180 | rbind(df.stat) -> df.stat 181 | 182 | df %>% 183 | dplyr::mutate(temp = paste0(Gene, Treatment)) %>% 184 | dplyr::left_join(df.stat, by = "temp") -> df 185 | } 186 | } 187 | 188 | # plot 189 | df %>% 190 | dplyr::group_by(Gene, Treatment) %>% 191 | dplyr::mutate( 192 | mean.expre = mean(expre), 193 | sd.expre = stats::sd(expre), 194 | n = dplyr::n(), 195 | se = sd.expre / sqrt(n) 196 | ) %>% 197 | dplyr::ungroup() -> df.plot 198 | if (fig.type == "box") { 199 | df.plot %>% 200 | ggplot2::ggplot(ggplot2::aes(Treatment, expre, fill = Treatment)) + 201 | ggplot2::geom_boxplot(width = 0.6) + 202 | ggplot2::facet_wrap(. ~ Gene, scales = "free_y", ncol = fig.ncol) + 203 | ggplot2::geom_text(ggplot2::aes(Treatment, mean.expre, label = "."), 204 | check_overlap = TRUE, size = 15, color = "red" 205 | ) + 206 | ggplot2::geom_text(ggplot2::aes(Treatment, min(expre), label = signif), 207 | check_overlap = TRUE, size = 3, color = "black" 208 | ) + 209 | ggthemes::theme_pander() + 210 | ggplot2::labs(y = "Relative expression") + 211 | ggplot2::theme( 212 | legend.position = "none", 213 | strip.text.x = ggplot2::element_text(face = "italic") 214 | ) -> p 215 | } else if (fig.type == "bar") { 216 | df.plot %>% 217 | dplyr::group_by(Gene) %>% 218 | dplyr::mutate(max.temp = max(expre)) %>% 219 | ggplot2::ggplot(ggplot2::aes(Treatment, mean.expre / n, fill = Treatment)) + 220 | ggplot2::geom_bar(stat = "identity", width = 0.6) + 221 | ggplot2::geom_errorbar(ggplot2::aes(Treatment, 222 | ymin = mean.expre - sd.expre, 223 | ymax = mean.expre + sd.expre 224 | ), 225 | width = 0.2 226 | ) + 227 | ggplot2::geom_jitter(ggplot2::aes(Treatment, expre), width = 0.1, alpha = 0.4) + 228 | ggplot2::geom_hline(ggplot2::aes(yintercept = max.temp * 1.1), color = NA) + 229 | ggplot2::facet_wrap(. ~ Gene, scales = "free_y", ncol = fig.ncol) + 230 | ggplot2::geom_text(ggplot2::aes(Treatment, max.temp * 1.08, label = signif), 231 | check_overlap = TRUE, size = 4, color = "black" 232 | ) + 233 | ggthemes::theme_pander() + 234 | ggplot2::labs(y = "Relative expression") + 235 | ggplot2::theme( 236 | legend.position = "none", 237 | strip.text.x = ggplot2::element_text(face = "italic") 238 | ) -> p 239 | } 240 | 241 | res <- list(table = df.plot, figure = p) 242 | return(res) 243 | } 244 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/R/CalExpCurve.R: -------------------------------------------------------------------------------- 1 | #' @name CalExpCurve 2 | #' @author Xiang LI 3 | #' 4 | #' @title Calculate expression using standard curve. 5 | #' @description Calculate expression using standard curve. 6 | #' 7 | #' @param cq.table The data frame of the position and Cq value. 8 | #' @param design.table The data frame of the position and corresponding information. 9 | #' @param correction Correct expression value by reference gene. 10 | #' @param ref.gene The name of reference gene. 11 | #' @param stat.method Statistical method. 12 | #' @param ref.group The name of reference group. 13 | #' @param fig.type Output image type, `box` represents `boxplot`, `bar` represents `barplot`. 14 | #' @param fig.ncol Number of columes of figure. 15 | #' 16 | #' @importFrom dplyr left_join filter group_by mutate ungroup 17 | #' @importFrom stats lm 18 | #' @importFrom broom glance 19 | #' @importFrom ggplot2 ggplot aes geom_point geom_smooth labs theme_bw 20 | #' @importFrom ggpmisc stat_poly_eq 21 | #' 22 | #' @export 23 | #' 24 | #' @return A list contain a table and a figure. 25 | #' 26 | #' @examples 27 | #' df1.path = system.file("examples", "cal.exp.curve.cq.txt", package = "qPCRtools") 28 | #' df2.path = system.file("examples", "cal.expre.curve.sdc.txt", package = "qPCRtools") 29 | #' df3.path = system.file("examples", "cal.exp.curve.design.txt", package = "qPCRtools") 30 | #' 31 | #' cq.table = read.table(df1.path, header = TRUE) 32 | #' curve.table = read.table(df2.path, sep = "\t", header = TRUE) 33 | #' design.table = read.table(df3.path, header = TRUE) 34 | #' 35 | #' CalExpCurve( 36 | #' cq.table, 37 | #' curve.table, 38 | #' design.table, 39 | #' correction = TRUE, 40 | #' ref.gene = "OsUBQ", 41 | #' stat.method = "t.test", 42 | #' ref.group = "CK", 43 | #' fig.type = "box", 44 | #' fig.ncol = NULL) -> res 45 | #' 46 | #' res[["table"]] 47 | #' res[["figure"]] 48 | #' 49 | globalVariables(c( 50 | "cq.table", 51 | "curve.table", 52 | "design.table", 53 | "correction", 54 | "ref.gene", 55 | "stat.method", 56 | "ref.group", 57 | "fig.type", 58 | "fig.ncol", 59 | "out", 60 | "Cq", 61 | "max.Cq", 62 | "min.Cq", 63 | "expre", 64 | "Intercept", 65 | "Slope", 66 | "Treatment", 67 | "element_text", 68 | "group2", 69 | "max.temp", 70 | "mean.expre", 71 | "mean.ref", 72 | "n", 73 | "sd", 74 | "sd.expre", 75 | "Treatment", 76 | "mean.ref", 77 | "group2", 78 | "temp", 79 | "n", 80 | "sd.expre", 81 | "n", 82 | "mean.expre", 83 | "element_text", 84 | "max.temp" 85 | )) 86 | CalExpCurve <- function(cq.table, 87 | curve.table, 88 | design.table, 89 | correction = TRUE, 90 | ref.gene = "OsUBQ", 91 | stat.method = "t.test", 92 | ref.group = "CK", 93 | fig.type = "box", 94 | fig.ncol = NULL) { 95 | # merge data 96 | cq.table %>% 97 | dplyr::left_join(design.table, by = "Position") %>% 98 | dplyr::left_join(curve.table, by = "Gene") %>% 99 | dplyr::mutate(out = dplyr::case_when( 100 | Cq > max.Cq | Cq < min.Cq ~ "yes", 101 | TRUE ~ "no" 102 | )) %>% 103 | dplyr::mutate(expre = (Cq - Intercept) / Slope) -> df 104 | 105 | # print warning message 106 | df.out <- df %>% 107 | dplyr::filter(out == "yes") 108 | if (dim(df.out)[1] != 0) { 109 | warning(paste0("Cq of ", as.character(df.out$Position), " out of curve range!")) 110 | } 111 | 112 | if (isTRUE(correction)) { 113 | df %>% 114 | dplyr::filter(Gene == ref.gene) %>% 115 | dplyr::group_by(Treatment) %>% 116 | dplyr::summarise(mean.ref = mean(expre)) %>% 117 | dplyr::ungroup() %>% 118 | dplyr::left_join(df, by = "Treatment") %>% 119 | dplyr::filter(Gene != ref.gene) %>% 120 | dplyr::mutate(expre = expre / mean.ref) %>% 121 | dplyr::select(Treatment, Gene, expre) -> df 122 | } else { 123 | df %>% 124 | dplyr::select(Treatment, Gene, expre) -> df 125 | } 126 | 127 | # statistics 128 | if (stat.method == "t.test") { 129 | df %>% 130 | dplyr::group_by(Gene) %>% 131 | rstatix::t_test(expre ~ Treatment, ref.group = ref.group) %>% 132 | dplyr::select(Gene, group2, p) %>% 133 | dplyr::mutate(temp = paste0(Gene, group2)) %>% 134 | dplyr::select(temp, p) %>% 135 | dplyr::mutate(signif = dplyr::case_when( 136 | p < 0.001 ~ "***", 137 | p > 0.001 & p < 0.01 ~ "**", 138 | p > 0.01 & p < 0.05 ~ "*", 139 | TRUE ~ "NS" 140 | )) %>% 141 | dplyr::select(temp, signif) -> df.stat 142 | 143 | df %>% 144 | dplyr::mutate(temp = paste0(Gene, Treatment)) %>% 145 | dplyr::left_join(df.stat, by = "temp") -> df 146 | } else if (stat.method == "wilcox.test") { 147 | df %>% 148 | dplyr::group_by(Gene) %>% 149 | rstatix::wilcox_test(expre ~ Treatment, ref.group = ref.group) %>% 150 | dplyr::select(Gene, group2, p) %>% 151 | dplyr::mutate(temp = paste0(Gene, group2)) %>% 152 | dplyr::select(temp, p) %>% 153 | dplyr::mutate(signif = dplyr::case_when( 154 | p < 0.001 ~ "***", 155 | p > 0.001 & p < 0.01 ~ "**", 156 | p > 0.01 & p < 0.05 ~ "*", 157 | TRUE ~ "NS" 158 | )) %>% 159 | dplyr::select(temp, signif) -> df.stat 160 | 161 | df %>% 162 | dplyr::mutate(temp = paste0(Gene, Treatment)) %>% 163 | dplyr::left_join(df.stat, by = "temp") -> df 164 | } else if (stat.method == "anova") { 165 | df.stat <- NULL 166 | for (i in unique(df$Gene)) { 167 | df.sub <- df %>% 168 | dplyr::filter(Gene == i) %>% 169 | dplyr::mutate(Treatment = factor(Treatment)) 170 | fit <- stats::aov(expre ~ Treatment, data = df.sub) 171 | tuk <- multcomp::glht(fit, linfct = multcomp::mcp(Treatment = "Tukey")) 172 | multcomp::cld(tuk, level = 0.95, ddecreasing = TRUE)[["mcletters"]][["Letters"]] %>% 173 | as.data.frame() %>% 174 | dplyr::mutate(Gene = i) %>% 175 | tibble::rownames_to_column(var = "Treatment") %>% 176 | magrittr::set_colnames(c("Treatment", "signif", "Gene")) %>% 177 | dplyr::select(Gene, Treatment, signif) %>% 178 | dplyr::mutate(temp = paste0(Gene, Treatment)) %>% 179 | dplyr::select(temp, signif) %>% 180 | rbind(df.stat) -> df.stat 181 | 182 | df %>% 183 | dplyr::mutate(temp = paste0(Gene, Treatment)) %>% 184 | dplyr::left_join(df.stat, by = "temp") -> df 185 | } 186 | } 187 | 188 | # plot 189 | df %>% 190 | dplyr::group_by(Gene, Treatment) %>% 191 | dplyr::mutate( 192 | mean.expre = mean(expre), 193 | sd.expre = stats::sd(expre), 194 | n = dplyr::n(), 195 | se = sd.expre / sqrt(n) 196 | ) %>% 197 | dplyr::ungroup() -> df.plot 198 | if (fig.type == "box") { 199 | df.plot %>% 200 | ggplot2::ggplot(ggplot2::aes(Treatment, expre, fill = Treatment)) + 201 | ggplot2::geom_boxplot(width = 0.6) + 202 | ggplot2::facet_wrap(. ~ Gene, scales = "free_y", ncol = fig.ncol) + 203 | ggplot2::geom_text(ggplot2::aes(Treatment, mean.expre, label = "."), 204 | check_overlap = TRUE, size = 15, color = "red" 205 | ) + 206 | ggplot2::geom_text(ggplot2::aes(Treatment, min(expre), label = signif), 207 | check_overlap = TRUE, size = 3, color = "black" 208 | ) + 209 | ggthemes::theme_pander() + 210 | ggplot2::labs(y = "Relative expression") + 211 | ggplot2::theme( 212 | legend.position = "none", 213 | strip.text.x = ggplot2::element_text(face = "italic") 214 | ) -> p 215 | } else if (fig.type == "bar") { 216 | df.plot %>% 217 | dplyr::group_by(Gene) %>% 218 | dplyr::mutate(max.temp = max(expre)) %>% 219 | ggplot2::ggplot(ggplot2::aes(Treatment, mean.expre / n, fill = Treatment)) + 220 | ggplot2::geom_bar(stat = "identity", width = 0.6) + 221 | ggplot2::geom_errorbar(ggplot2::aes(Treatment, 222 | ymin = mean.expre - sd.expre, 223 | ymax = mean.expre + sd.expre 224 | ), 225 | width = 0.2 226 | ) + 227 | ggplot2::geom_jitter(ggplot2::aes(Treatment, expre), width = 0.1, alpha = 0.4) + 228 | ggplot2::geom_hline(ggplot2::aes(yintercept = max.temp * 1.1), color = NA) + 229 | ggplot2::facet_wrap(. ~ Gene, scales = "free_y", ncol = fig.ncol) + 230 | ggplot2::geom_text(ggplot2::aes(Treatment, max.temp * 1.08, label = signif), 231 | check_overlap = TRUE, size = 4, color = "black" 232 | ) + 233 | ggthemes::theme_pander() + 234 | ggplot2::labs(y = "Relative expression") + 235 | ggplot2::theme( 236 | legend.position = "none", 237 | strip.text.x = ggplot2::element_text(face = "italic") 238 | ) -> p 239 | } 240 | 241 | res <- list(table = df.plot, figure = p) 242 | return(res) 243 | } 244 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Install 2 | 3 | ```{r 4 | install.packages("qPCRtools") 5 | ``` 6 | 7 | ## Calculate volume for reverse transcription 8 | 9 | The first step of qPCR is usually the preparation of cDNA. We need to calculate the column of RNA for reverse transcription to cDNA. So, if we have the concentration of RNA, we can use the function `CalRTable` to do that. The function have three patameters: 10 | 11 | - `data`: The table of RNA concentration. The unit of concentration is ng/μl. The demo data can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/crtv.data.txt). 12 | - `template`: The table of reagent for reverse transcription. The demo data can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/crtv.template.txt). The column `All` is the total volume for 1 μg RNA. 13 | - `RNA.weight`: The mass of RNA. The unit is μg. The default value is 2. 14 | 15 | ```{r 16 | suppressMessages(library(tidyverse)) 17 | library(qPCRtools) 18 | 19 | df.1.path <- system.file("examples", "crtv.data.txt", package = "qPCRtools") 20 | df.2.path <- system.file("examples", "crtv.template.txt", package = "qPCRtools") 21 | df.1 <- data.table::fread(df.1.path) 22 | df.2 <- data.table::fread(df.2.path) 23 | result <- CalRTable(data = df.1, template = df.2, RNA.weight = 2) 24 | 25 | result %>% 26 | dplyr::slice(1:6) %>% 27 | kableExtra::kable(format = "html") %>% 28 | kableExtra::kable_styling("striped") 29 | ``` 30 | 31 | ## Calculate standard curve 32 | 33 | The function can calculate the standard curve. At the same time, it can get the amplification efficiency of primer(s). Based on the amplification efficiency, we can know which method can be used to calculate the expression level. The function has 6 parameters: 34 | 35 | - `cq.table`: The table of Cq. It must contain at least two columns:One `Position` and `Cq`. The demo data can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/calsc.cq.txt). 36 | - `concen.table`: The table of gene(s) and concentration. It must contain at least three columns: `Position`, `Gene` and `Conc`. The demo data can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/calsc.info.txt). 37 | - `lowest.concen`: The lowest concentration used to calculate the standard curve. 38 | - `highest.concen`: The highest concentration used to calculate the standard curve. 39 | - `dilu`: The dilution factor of cDNA template. The default value is 4. 40 | - `by`: Calculate the standard curve by average data or the full data. The default value is `mean`. 41 | 42 | ```{r 43 | library(qPCRtools) 44 | 45 | df.1.path <- system.file("examples", "calsc.cq.txt", package = "qPCRtools") 46 | df.2.path <- system.file("examples", "calsc.info.txt", package = "qPCRtools") 47 | df.1 <- data.table::fread(df.1.path) 48 | df.2 <- data.table::fread(df.2.path) 49 | CalCurve( 50 | cq.table = df.1, 51 | concen.table = df.2, 52 | lowest.concen = 4, 53 | highest.concen = 4096, 54 | dilu = 4, 55 | by = "mean" 56 | ) -> p 57 | 58 | p[["table"]] %>% 59 | dplyr::slice(1:6) %>% 60 | kableExtra::kable(format = "html") %>% 61 | kableExtra::kable_styling("striped") 62 | 63 | p[["figure"]] 64 | 65 | ``` 66 | 67 | ## Calculate expression using standard curve 68 | 69 | After we calculated the standard curve, we can use the standard curve to calculate the expression level of genes. In `qPCRtools`, function `CalExpCurve` can get the expression using standard curve. There are several parameters in this function: 70 | 71 | - `cq.table`: The table of Cq. It must contain at least two columns:One `Position` and `Cq`. The demo data can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/cal.exp.curve.cq.csv). 72 | - `curve.table`: The table of standard curve calculated by `CalCurve`. 73 | - `design.table`: The design information including three columns: `Position`, `Treatment` and `Gene`. The demo table can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/cal.exp.curve.design.txt). 74 | - `correction`: Expression level is corrected or not with internal reference genes. The default value is `TRUE`. 75 | - `ref.gene`: The name of reference gene. 76 | - `stat.method`: The method used to calculate differential expression of genes. If we want to calculate the difference between target group and reference group, one of `t.test` or `wilcox.test` can be used. `anova` is for all groups. The default value is `t.test`. 77 | - `ref.group`: The name of reference group. If `stat.method` is `t.test` or `wilcox.test`, the function need a `ref.group`. 78 | - `fig.type`: The type of figure, `box` or `bar`. `box` represents `boxplot`. `bar` represents `barplot`. The default value is `box`. 79 | - `fig.ncol`: The column of figure. The default value is `NULL`. 80 | 81 | ```{r} 82 | df1.path = system.file("examples", "cal.exp.curve.cq.txt", package = "qPCRtools") 83 | df2.path = system.file("examples", "cal.expre.curve.sdc.txt", package = "qPCRtools") 84 | df3.path = system.file("examples", "cal.exp.curve.design.txt", package = "qPCRtools") 85 | 86 | cq.table = data.table::fread(df1.path) 87 | curve.table = data.table::fread(df2.path) 88 | design.table = data.table::fread(df3.path) 89 | 90 | CalExpCurve( 91 | cq.table, 92 | curve.table, 93 | design.table, 94 | correction = TRUE, 95 | ref.gene = "OsUBQ", 96 | stat.method = "t.test", 97 | ref.group = "CK", 98 | fig.type = "box", 99 | fig.ncol = NULL) -> res 100 | 101 | res[["table"]] %>% 102 | dplyr::slice(1:6) %>% 103 | kableExtra::kable(format = "html") %>% 104 | kableExtra::kable_styling("striped") 105 | res[["figure"]] 106 | ``` 107 | 108 | ## Calculate expression using 2-ΔΔCt 109 | 110 | $2^{-{Δ}{Δ}{C_t }} $is a widely used method to calculate qPCR data[@livak2001analysis]. Our function `CalExp2ddCt` can do it. Seven parameters are required for this function: 111 | 112 | - `cq.table`: The demo file can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/ddct.cq.txt). 113 | - `design.table`: The demo data can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/ddct.design.txt). 114 | Other parameters are same as the function `CalExpCurve`. 115 | - `ref.gene`: The name of reference gene. 116 | - `ref.group`: The name of reference group. If `stat.method` is `t.test` or `wilcox.test`, the function need a `ref.group`. 117 | - `stat.method`: The method used to calculate differential expression of genes. If we want to calculate the difference between target group and reference group, one of `t.test` or `wilcox.test` can be used. `anova` is for all groups. The default value is `t.test`. 118 | - `fig.type`: The type of figure, `box` or `bar`. `box` represents `boxplot`. `bar` represents `barplot`. The default value is `box`. 119 | - `fig.ncol`: The column of figure. The default value is `NULL`. 120 | 121 | ```{r 122 | df1.path = system.file("examples", "ddct.cq.txt", package = "qPCRtools") 123 | df2.path = system.file("examples", "ddct.design.txt", package = "qPCRtools") 124 | 125 | cq.table = data.table::fread(df1.path) 126 | design.table = data.table::fread(df2.path) 127 | 128 | CalExp2ddCt(cq.table, 129 | design.table, 130 | ref.gene = "OsUBQ", 131 | ref.group = "CK", 132 | stat.method = "t.test", 133 | fig.type = "bar", 134 | fig.ncol = NULL) -> res 135 | 136 | res[["table"]] %>% 137 | dplyr::slice(1:6) %>% 138 | kableExtra::kable(format = "html") %>% 139 | kableExtra::kable_styling("striped") 140 | 141 | res[["figure"]] 142 | ``` 143 | 144 | ## Calculate expression using RqPCR 145 | 146 | The method from [SATQPCR](http://satqpcr.sophia.inra.fr/cgi/home.cgi) can identify the most stable reference genes (REF) across biological replicates and technical replicates[@rancurel2019satqpcr]. Our package provides a function, `CalExpRqPCR`, to achieve it. In the `design.table`, `BioRep`, `TechRep` and `Eff` are required. `BioRep` is the `biological replicates`. `TechRep` is the `technical replicates`. `Eff` is the amplification efficiency of genes. The `cq.table` can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/cal.expre.rqpcr.cq.txt) and the `design,table` can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/cal.expre.rqpcr.design.txt). If user want to give reference gene, `ref.gene` can be used (The default is `NULL`). 147 | 148 | - `ref.group`: The name of reference group. If `stat.method` is `t.test` or `wilcox.test`, the function need a `ref.group`. 149 | - `stat.method`: The method used to calculate differential expression of genes. If we want to calculate the difference between target group and reference group, one of `t.test` or `wilcox.test` can be used. `anova` is for all groups. The default value is `t.test`. 150 | - `fig.type`: The type of figure, `box` or `bar`. `box` represents `boxplot`. `bar` represents `barplot`. The default value is `box`. 151 | - `fig.ncol`: The column of figure. The default value is `NULL`. 152 | 153 | ```{r 154 | df1.path <- system.file("examples", "cal.expre.rqpcr.cq.txt", package = "qPCRtools") 155 | df2.path <- system.file("examples", "cal.expre.rqpcr.design.txt", package = "qPCRtools") 156 | 157 | cq.table <- data.table::fread(df1.path, header = TRUE) 158 | design.table <- data.table::fread(df2.path, header = TRUE) 159 | 160 | CalExpRqPCR(cq.table, 161 | design.table, 162 | ref.gene = NULL, 163 | ref.group = "CK", 164 | stat.method = "t.test", 165 | fig.type = "bar", 166 | fig.ncol = NULL 167 | ) -> res 168 | 169 | res[["table"]] %>% 170 | dplyr::slice(1:6) %>% 171 | kableExtra::kable(format = "html") %>% 172 | kableExtra::kable_styling("striped") 173 | 174 | res[["figure"]] 175 | ``` 176 | 177 | ## References 178 | 179 | If this package is used in your publication, please cite `qPCRtools` paper: 180 | 181 | >[Li X, Wang Y, Li J, et al. qPCRtools: An R package for qPCR data processing and visualization[J]. Frontiers in Genetics, 2022, 13: 1002704.](https://www.frontiersin.org/articles/10.3389/fgene.2022.1002704/full) 182 | -------------------------------------------------------------------------------- /vignettes/qPCRtools.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "qPCRtools introduction" 3 | output: rmarkdown::html_vignette 4 | vignette: > 5 | %\VignetteIndexEntry{qPCRtools introduction} 6 | %\VignetteEngine{knitr::rmarkdown} 7 | %\VignetteEncoding{UTF-8} 8 | bibliography: lib.bib 9 | csl: chinese-gb7714-2005-numeric.csl 10 | --- 11 | 12 | ## Install 13 | 14 | ```{r eval=FALSE} 15 | install.packages("qPCRtools") 16 | ``` 17 | 18 | ## Calculate volume for reverse transcription 19 | 20 | The first step of qPCR is usually the preparation of cDNA. We need to calculate the column of RNA for reverse transcription to cDNA. So, if we have the concentration of RNA, we can use the function `CalRTable` to do that. The function have three patameters: 21 | 22 | - `data`: The table of RNA concentration. The unit of concentration is ng/μl. The demo data can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/crtv.data.txt). 23 | - `template`: The table of reagent for reverse transcription. The demo data can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/crtv.template.txt). The column `all` that must be in this `data.frame` is the total volume for 1 μg RNA. 24 | - `RNA.weight`: The mass of RNA. The unit is μg. The default value is 2. 25 | 26 | ```{r echo=TRUE} 27 | library(magrittr) 28 | 29 | df.1.path <- system.file("examples", "crtv.data.txt", package = "qPCRtools") 30 | df.2.path <- system.file("examples", "crtv.template.txt", package = "qPCRtools") 31 | df.1 <- data.table::fread(df.1.path) 32 | df.2 <- data.table::fread(df.2.path) 33 | result <- qPCRtools::CalRTable(data = df.1, template = df.2, RNA.weight = 2) 34 | 35 | result %>% 36 | dplyr::slice(1:6) %>% 37 | kableExtra::kable(format = "html") %>% 38 | kableExtra::kable_styling("striped") 39 | ``` 40 | 41 | ## Calculate standard curve 42 | 43 | The function can calculate the standard curve. At the same time, it can get the amplification efficiency of primer(s). Based on the amplification efficiency, we can know which method can be used to calculate the expression level. The function has 6 parameters: 44 | 45 | - `cq.table`: The table of Cq. It must contain at least two columns:One `Position` and `Cq`. The demo data can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/calsc.cq.txt). 46 | - `concen.table`: The table of gene(s) and concentration. It must contain at least three columns: `Position`, `Gene` and `Conc`. The demo data can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/calsc.info.txt). 47 | - `lowest.concen`: The lowest concentration used to calculate the standard curve. 48 | - `highest.concen`: The highest concentration used to calculate the standard curve. 49 | - `dilu`: The dilution factor of cDNA template. The default value is 4. 50 | - `by`: Calculate the standard curve by average data or the full data. The default value is `mean`. 51 | 52 | ```{r echo=TRUE} 53 | library(qPCRtools) 54 | 55 | df.1.path <- system.file("examples", "calsc.cq.txt", package = "qPCRtools") 56 | df.2.path <- system.file("examples", "calsc.info.txt", package = "qPCRtools") 57 | df.1 <- data.table::fread(df.1.path) 58 | df.2 <- data.table::fread(df.2.path) 59 | qPCRtools::CalCurve( 60 | cq.table = df.1, 61 | concen.table = df.2, 62 | lowest.concen = 4, 63 | highest.concen = 4096, 64 | dilu = 4, 65 | by = "mean" 66 | ) -> p 67 | 68 | p[["table"]] %>% 69 | dplyr::slice(1:6) %>% 70 | kableExtra::kable(format = "html") %>% 71 | kableExtra::kable_styling("striped") 72 | 73 | p[["figure"]] 74 | 75 | ``` 76 | 77 | ## Calculate expression using standard curve 78 | After we calculated the standard curve, we can use the standard curve to calculate the expression level of genes. In `qPCRtools`, function `CalExpCurve` can get the expression using standard curve. There are several parameters in this function: 79 | - `cq.table`: The table of Cq. It must contain at least two columns:One `Position` and `Cq`. The demo data can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/cal.exp.curve.cq.csv). 80 | - `curve.table`: The table of standard curve calculated by `CalCurve`. 81 | - `design.table`: The design information including three columns: `Position`, `Treatment` and `Gene`. The demo table can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/cal.exp.curve.design.txt). 82 | - `correction`: Expression level is corrected or not with internal reference genes. The default value is `TRUE`. 83 | - `ref.gene`: The name of reference gene. 84 | - `stat.method`: The method used to calculate differential expression of genes. If we want to calculate the difference between target group and reference group, one of `t.test` or `wilcox.test` can be used. `anova` is for all groups. The default value is `t.test`. 85 | - `ref.group`: The name of reference group. If `stat.method` is `t.test` or `wilcox.test`, the function need a `ref.group`. 86 | - `fig.type`: The type of figure, `box` or `bar`. `box` represents `boxplot`. `bar` represents `barplot`. The default value is `box`. 87 | - `fig.ncol`: The column of figure. The default value is `NULL`. 88 | 89 | 90 | 91 | ```{r} 92 | df1.path = system.file("examples", "cal.exp.curve.cq.txt", package = "qPCRtools") 93 | df2.path = system.file("examples", "cal.expre.curve.sdc.txt", package = "qPCRtools") 94 | df3.path = system.file("examples", "cal.exp.curve.design.txt", package = "qPCRtools") 95 | 96 | cq.table = data.table::fread(df1.path) 97 | curve.table = data.table::fread(df2.path) 98 | design.table = data.table::fread(df3.path) 99 | 100 | qPCRtools::CalExpCurve( 101 | cq.table, 102 | curve.table, 103 | design.table, 104 | correction = TRUE, 105 | ref.gene = "OsUBQ", 106 | stat.method = "t.test", 107 | ref.group = "CK", 108 | fig.type = "box", 109 | fig.ncol = NULL) -> res 110 | 111 | res[["table"]] %>% 112 | dplyr::slice(1:6) %>% 113 | kableExtra::kable(format = "html") %>% 114 | kableExtra::kable_styling("striped") 115 | res[["figure"]] 116 | ``` 117 | 118 | ## Calculate expression using 2-ΔΔCt 119 | $2^{-{Δ}{Δ}{C_t }} $is a widely used method to calculate qPCR data[@livak2001analysis]. Our function `CalExp2ddCt` can do it. Seven parameters are required for this function: 120 | - `cq.table`: The demo file can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/ddct.cq.txt). 121 | - `design.table`: The demo data can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/ddct.design.txt). 122 | Other parameters are same as the function `CalExpCurve`. 123 | - `ref.gene`: The name of reference gene. 124 | - `ref.group`: The name of reference group. If `stat.method` is `t.test` or `wilcox.test`, the function need a `ref.group`. 125 | - `stat.method`: The method used to calculate differential expression of genes. If we want to calculate the difference between target group and reference group, one of `t.test` or `wilcox.test` can be used. `anova` is for all groups. The default value is `t.test`. 126 | - `fig.type`: The type of figure, `box` or `bar`. `box` represents `boxplot`. `bar` represents `barplot`. The default value is `box`. 127 | - `fig.ncol`: The column of figure. The default value is `NULL`. 128 | 129 | ```{r echo=TRUE} 130 | df1.path = system.file("examples", "ddct.cq.txt", package = "qPCRtools") 131 | df2.path = system.file("examples", "ddct.design.txt", package = "qPCRtools") 132 | 133 | cq.table = data.table::fread(df1.path) 134 | design.table = data.table::fread(df2.path) 135 | 136 | qPCRtools::CalExp2ddCt(cq.table, 137 | design.table, 138 | ref.gene = "OsUBQ", 139 | ref.group = "CK", 140 | stat.method = "t.test", 141 | fig.type = "bar", 142 | fig.ncol = NULL) -> res 143 | 144 | res[["table"]] %>% 145 | dplyr::slice(1:6) %>% 146 | kableExtra::kable(format = "html") %>% 147 | kableExtra::kable_styling("striped") 148 | 149 | res[["figure"]] 150 | ``` 151 | 152 | ## Calculate expression using RqPCR 153 | The method from [SATQPCR](http://satqpcr.sophia.inra.fr/cgi/home.cgi) can identify the most stable reference genes (REF) across biological replicates and technical replicates[@rancurel2019satqpcr]. Our package provides a function, `CalExpRqPCR`, to achieve it. In the `design.table`, `BioRep`, `TechRep` and `Eff` are required. `BioRep` is the `biological replicates`. `TechRep` is the `technical replicates`. `Eff` is the amplification efficiency of genes. 154 | 155 | - The `cq.table` can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/cal.expre.rqpcr.cq.txt). 156 | - The `design,table` can be found at [GitHub](https://github.com/lixiang117423/qPCRtools/blob/main/CRAN/qPCRtools/inst/examples/cal.expre.rqpcr.design.txt). If user want to give reference gene, `ref.gene` can be used (The default is `NULL`). 157 | - `ref.gene`: The name of reference gene. 158 | - `ref.group`: The name of reference group. If `stat.method` is `t.test` or `wilcox.test`, the function need a `ref.group`. 159 | - `stat.method`: The method used to calculate differential expression of genes. If we want to calculate the difference between target group and reference group, one of `t.test` or `wilcox.test` can be used. `anova` is for all groups. The default value is `t.test`. 160 | - `fig.type`: The type of figure, `box` or `bar`. `box` represents `boxplot`. `bar` represents `barplot`. The default value is `box`. 161 | - `fig.ncol`: The column of figure. The default value is `NULL`. 162 | 163 | ```{r echo=TRUE} 164 | df1.path <- system.file("examples", "cal.expre.rqpcr.cq.txt", package = "qPCRtools") 165 | df2.path <- system.file("examples", "cal.expre.rqpcr.design.txt", package = "qPCRtools") 166 | 167 | cq.table <- data.table::fread(df1.path, header = TRUE) 168 | design.table <- data.table::fread(df2.path, header = TRUE) 169 | 170 | qPCRtools::CalExpRqPCR(cq.table, 171 | design.table, 172 | ref.gene = NULL, 173 | ref.group = "CK", 174 | stat.method = "t.test", 175 | fig.type = "bar", 176 | fig.ncol = NULL 177 | ) -> res 178 | 179 | res[["table"]] %>% 180 | dplyr::slice(1:6) %>% 181 | kableExtra::kable(format = "html") %>% 182 | kableExtra::kable_styling("striped") 183 | 184 | res[["figure"]] 185 | ``` 186 | 187 | ## References 188 | -------------------------------------------------------------------------------- /inst/examples/cal.exp.curve.cq.csv: -------------------------------------------------------------------------------- 1 | Batch,Color,Position,Sample Name,Gene Name,Cq,Concentration,Call,Excluded,Sample Type,Standard,Cq Mean,Cq Error,Concentration Mean,Concentration Error,Replicate Group,Dye,Edited Call,Slope,EPF,Failure,Notes,Sample Prep Notes,Number 2 | 2,155;67;123;181,A1,Sample 1,None,27.83,-,Positive,Unchecked,Unknown,-,27.83,0,-,-,3,155;67;123;182,A2,Sample 2,None,28.83,-,Positive,Unchecked 3 | 2,155;67;123;181,A2,Sample 2,None,25.81,-,Positive,Unchecked,Unknown,-,25.81,0,-,-,,SYBR Green I, ,1.14,4.17,None,,,2 4 | 2,155;67;123;181,A3,Sample 3,None,34.97,-,Positive,Unchecked,Unknown,-,34.97,0,-,-,,SYBR Green I, ,0.61,2.39,None,,,3 5 | 2,155;67;123;181,A4,Sample 4,None,29.15,-,Positive,Unchecked,Unknown,-,29.15,0,-,-,,SYBR Green I, ,0.89,3.42,None,,,4 6 | 2,155;67;123;181,A5,Sample 5,None,31.96,-,Positive,Unchecked,Unknown,-,31.96,0,-,-,,SYBR Green I, ,1.19,4.11,None,,,5 7 | 2,155;67;123;181,A6,Sample 6,None,33.31,-,Positive,Unchecked,Unknown,-,33.31,0,-,-,,SYBR Green I, ,1.07,3.88,None,,,6 8 | 2,155;67;123;181,A7,Sample 7,None,28.97,-,Positive,Unchecked,Unknown,-,28.97,0,-,-,,SYBR Green I, ,0.69,3.1,None,,,7 9 | 2,155;67;123;181,A8,Sample 8,None,26.47,-,Positive,Unchecked,Unknown,-,26.47,0,-,-,,SYBR Green I, ,1.23,4.32,None,,,8 10 | 2,155;67;123;181,A9,Sample 9,None,31.89,-,Positive,Unchecked,Unknown,-,31.89,0,-,-,,SYBR Green I, ,0.59,2.65,None,,,9 11 | 2,155;67;123;181,A10,Sample 10,None,30.01,-,Positive,Unchecked,Unknown,-,30.01,0,-,-,,SYBR Green I, ,0.91,3.42,None,,,10 12 | 2,155;67;123;181,A11,Sample 11,None,34.94,-,Positive,Unchecked,Unknown,-,34.94,0,-,-,,SYBR Green I, ,1.21,4.19,None,,,11 13 | 2,155;67;123;181,A12,Sample 12,None,33.89,-,Positive,Unchecked,Unknown,-,33.89,0,-,-,,SYBR Green I, ,1.19,4.03,None,,,12 14 | 2,155;67;123;181,B1,Sample 13,None,27.57,-,Positive,Unchecked,Unknown,-,27.57,0,-,-,,SYBR Green I, ,0.81,3.49,None,,,13 15 | 2,155;67;123;181,B2,Sample 14,None,25.79,-,Positive,Unchecked,Unknown,-,25.79,0,-,-,,SYBR Green I, ,1,3.85,None,,,14 16 | 2,155;67;123;181,B3,Sample 15,None,32.04,-,Positive,Unchecked,Unknown,-,32.04,0,-,-,,SYBR Green I, ,0.58,2.57,None,,,15 17 | 2,155;67;123;181,B4,Sample 16,None,29.21,-,Positive,Unchecked,Unknown,-,29.21,0,-,-,,SYBR Green I, ,0.87,3.39,None,,,16 18 | 2,155;67;123;181,B5,Sample 17,None,33,-,Positive,Unchecked,Unknown,-,33,0,-,-,,SYBR Green I, ,1.09,4.15,None,,,17 19 | 2,155;67;123;181,B6,Sample 18,None,33.75,-,Positive,Unchecked,Unknown,-,33.75,0,-,-,,SYBR Green I, ,1.11,3.89,None,,,18 20 | 2,155;67;123;181,B7,Sample 19,None,29.02,-,Positive,Unchecked,Unknown,-,29.02,0,-,-,,SYBR Green I, ,0.71,3.16,None,,,19 21 | 2,155;67;123;181,B8,Sample 20,None,26.48,-,Positive,Unchecked,Unknown,-,26.48,0,-,-,,SYBR Green I, ,1.25,4.37,None,,,20 22 | 2,155;67;123;181,B9,Sample 21,None,30.91,-,Positive,Unchecked,Unknown,-,30.91,0,-,-,,SYBR Green I, ,0.65,2.93,None,,,21 23 | 2,155;67;123;181,B10,Sample 22,None,29.96,-,Positive,Unchecked,Unknown,-,29.96,0,-,-,,SYBR Green I, ,0.89,3.43,None,,,22 24 | 2,155;67;123;181,B11,Sample 23,None,33.76,-,Positive,Unchecked,Unknown,-,33.76,0,-,-,,SYBR Green I, ,1.18,4.19,None,,,23 25 | 2,155;67;123;181,B12,Sample 24,None,35.68,-,Positive,Unchecked,Unknown,-,35.68,0,-,-,,SYBR Green I, ,1.14,3.92,None,,,24 26 | 2,155;67;123;181,C1,Sample 25,None,27.53,-,Positive,Unchecked,Unknown,-,27.53,0,-,-,,SYBR Green I, ,0.75,3.36,None,,,25 27 | 2,155;67;123;181,C2,Sample 26,None,25.48,-,Positive,Unchecked,Unknown,-,25.48,0,-,-,,SYBR Green I, ,1.14,4.17,None,,,26 28 | 2,155;67;123;181,C3,Sample 27,None,32.29,-,Positive,Unchecked,Unknown,-,32.29,0,-,-,,SYBR Green I, ,0.59,2.56,None,,,27 29 | 2,155;67;123;181,C4,Sample 28,None,28.91,-,Positive,Unchecked,Unknown,-,28.91,0,-,-,,SYBR Green I, ,0.86,3.37,None,,,28 30 | 2,155;67;123;181,C5,Sample 29,None,34.54,-,Positive,Unchecked,Unknown,-,34.54,0,-,-,,SYBR Green I, ,1.04,3.93,None,,,29 31 | 2,155;67;123;181,C6,Sample 30,None,31.18,-,Positive,Unchecked,Unknown,-,31.18,0,-,-,,SYBR Green I, ,0.97,3.67,None,,,30 32 | 2,155;67;123;181,C7,Sample 31,None,27.02,-,Positive,Unchecked,Unknown,-,27.02,0,-,-,,SYBR Green I, ,0.65,3.07,None,,,31 33 | 2,155;67;123;181,C8,Sample 32,None,24.15,-,Positive,Unchecked,Unknown,-,24.15,0,-,-,,SYBR Green I, ,0.94,3.8,None,,,32 34 | 2,155;67;123;181,C9,Sample 33,None,29.19,-,Positive,Unchecked,Unknown,-,29.19,0,-,-,,SYBR Green I, ,0.54,2.79,None,,,33 35 | 2,155;67;123;181,C10,Sample 34,None,27.76,-,Positive,Unchecked,Unknown,-,27.76,0,-,-,,SYBR Green I, ,0.75,3.12,None,,,34 36 | 2,155;67;123;181,C11,Sample 35,None,29.6,-,Positive,Unchecked,Unknown,-,29.6,0,-,-,,SYBR Green I, ,1.18,4.01,None,,,35 37 | 2,155;67;123;181,C12,Sample 36,None,31.59,-,Positive,Unchecked,Unknown,-,31.59,0,-,-,,SYBR Green I, ,1.18,4.08,None,,,36 38 | 2,155;67;123;181,D1,Sample 37,None,27.3,-,Positive,Unchecked,Unknown,-,27.3,0,-,-,,SYBR Green I, ,0.85,3.61,None,,,37 39 | 2,155;67;123;181,D2,Sample 38,None,25.4,-,Positive,Unchecked,Unknown,-,25.4,0,-,-,,SYBR Green I, ,1.21,4.32,None,,,38 40 | 2,155;67;123;181,D3,Sample 39,None,31.22,-,Positive,Unchecked,Unknown,-,31.22,0,-,-,,SYBR Green I, ,0.64,2.85,None,,,39 41 | 2,155;67;123;181,D4,Sample 40,None,28.66,-,Positive,Unchecked,Unknown,-,28.66,0,-,-,,SYBR Green I, ,0.89,3.45,None,,,40 42 | 2,155;67;123;181,D5,Sample 41,None,32.07,-,Positive,Unchecked,Unknown,-,32.07,0,-,-,,SYBR Green I, ,1.35,4.38,None,,,41 43 | 2,155;67;123;181,D6,Sample 42,None,31.21,-,Positive,Unchecked,Unknown,-,31.21,0,-,-,,SYBR Green I, ,1.17,4.12,None,,,42 44 | 2,155;67;123;181,D7,Sample 43,None,27.25,-,Positive,Unchecked,Unknown,-,27.25,0,-,-,,SYBR Green I, ,0.77,3.42,None,,,43 45 | 2,155;67;123;181,D8,Sample 44,None,23.99,-,Positive,Unchecked,Unknown,-,23.99,0,-,-,,SYBR Green I, ,1.12,4.19,None,,,44 46 | 2,155;67;123;181,D9,Sample 45,None,29.37,-,Positive,Unchecked,Unknown,-,29.37,0,-,-,,SYBR Green I, ,0.64,3.06,None,,,45 47 | 2,155;67;123;181,D10,Sample 46,None,27.59,-,Positive,Unchecked,Unknown,-,27.59,0,-,-,,SYBR Green I, ,0.86,3.42,None,,,46 48 | 2,155;67;123;181,D11,Sample 47,None,30.53,-,Positive,Unchecked,Unknown,-,30.53,0,-,-,,SYBR Green I, ,1.28,4.25,None,,,47 49 | 2,155;67;123;181,D12,Sample 48,None,32,-,Positive,Unchecked,Unknown,-,32,0,-,-,,SYBR Green I, ,1.16,4.06,None,,,48 50 | 2,155;67;123;181,E1,Sample 49,None,28.13,-,Positive,Unchecked,Unknown,-,28.13,0,-,-,,SYBR Green I, ,0.83,3.49,None,,,49 51 | 2,155;67;123;181,E2,Sample 50,None,25.6,-,Positive,Unchecked,Unknown,-,25.6,0,-,-,,SYBR Green I, ,1.29,4.47,None,,,50 52 | 2,155;67;123;181,E3,Sample 51,None,30.63,-,Positive,Unchecked,Unknown,-,30.63,0,-,-,,SYBR Green I, ,0.64,2.91,None,,,51 53 | 2,155;67;123;181,E4,Sample 52,None,28.75,-,Positive,Unchecked,Unknown,-,28.75,0,-,-,,SYBR Green I, ,0.87,3.4,None,,,52 54 | 2,155;67;123;181,E5,Sample 53,None,32.45,-,Positive,Unchecked,Unknown,-,32.45,0,-,-,,SYBR Green I, ,1.14,4.15,None,,,53 55 | 2,155;67;123;181,E6,Sample 54,None,34.44,-,Positive,Unchecked,Unknown,-,34.44,0,-,-,,SYBR Green I, ,0.95,3.56,None,,,54 56 | 2,155;67;123;181,E7,Sample 55,None,27.94,-,Positive,Unchecked,Unknown,-,27.94,0,-,-,,SYBR Green I, ,0.67,3.09,None,,,55 57 | 2,155;67;123;181,E8,Sample 56,None,25.12,-,Positive,Unchecked,Unknown,-,25.12,0,-,-,,SYBR Green I, ,0.85,3.53,None,,,56 58 | 2,155;67;123;181,E9,Sample 57,None,29.36,-,Positive,Unchecked,Unknown,-,29.36,0,-,-,,SYBR Green I, ,0.56,2.83,None,,,57 59 | 2,155;67;123;181,E10,Sample 58,None,28.39,-,Positive,Unchecked,Unknown,-,28.39,0,-,-,,SYBR Green I, ,0.87,3.41,None,,,58 60 | 2,155;67;123;181,E11,Sample 59,None,32.08,-,Positive,Unchecked,Unknown,-,32.08,0,-,-,,SYBR Green I, ,1.18,4.22,None,,,59 61 | 2,155;67;123;181,E12,Sample 60,None,34.67,-,Positive,Unchecked,Unknown,-,34.67,0,-,-,,SYBR Green I, ,1.15,4.06,None,,,60 62 | 2,155;67;123;181,F1,Sample 61,None,27.87,-,Positive,Unchecked,Unknown,-,27.87,0,-,-,,SYBR Green I, ,0.83,3.51,None,,,61 63 | 2,155;67;123;181,F2,Sample 62,None,26.13,-,Positive,Unchecked,Unknown,-,26.13,0,-,-,,SYBR Green I, ,0.99,3.86,None,,,62 64 | 2,155;67;123;181,F3,Sample 63,None,31.37,-,Positive,Unchecked,Unknown,-,31.37,0,-,-,,SYBR Green I, ,0.55,2.55,None,,,63 65 | 2,155;67;123;181,F4,Sample 64,None,28.96,-,Positive,Unchecked,Unknown,-,28.96,0,-,-,,SYBR Green I, ,0.91,3.48,None,,,64 66 | 2,155;67;123;181,F5,Sample 65,None,32.91,-,Positive,Unchecked,Unknown,-,32.91,0,-,-,,SYBR Green I, ,1.15,4.1,None,,,65 67 | 2,155;67;123;181,F6,Sample 66,None,33.46,-,Positive,Unchecked,Unknown,-,33.46,0,-,-,,SYBR Green I, ,1.14,4.02,None,,,66 68 | 2,155;67;123;181,F7,Sample 67,None,27.49,-,Positive,Unchecked,Unknown,-,27.49,0,-,-,,SYBR Green I, ,0.72,3.25,None,,,67 69 | 2,155;67;123;181,F8,Sample 68,None,25.03,-,Positive,Unchecked,Unknown,-,25.03,0,-,-,,SYBR Green I, ,1.12,4.14,None,,,68 70 | 2,155;67;123;181,F9,Sample 69,None,30,-,Positive,Unchecked,Unknown,-,30,0,-,-,,SYBR Green I, ,0.43,2.33,None,,,69 71 | 2,155;67;123;181,F10,Sample 70,None,28.57,-,Positive,Unchecked,Unknown,-,28.57,0,-,-,,SYBR Green I, ,0.81,3.23,None,,,70 72 | 2,155;67;123;181,F11,Sample 71,None,31.87,-,Positive,Unchecked,Unknown,-,31.87,0,-,-,,SYBR Green I, ,1.08,4.05,None,,,71 73 | 2,155;67;123;181,F12,Sample 72,None,32.98,-,Positive,Unchecked,Unknown,-,32.98,0,-,-,,SYBR Green I, ,1.07,3.84,None,,,72 74 | 2,155;67;123;181,G1,Sample 73,None,27.97,-,Positive,Unchecked,Unknown,-,27.97,0,-,-,,SYBR Green I, ,0.83,3.54,None,,,73 75 | 2,155;67;123;181,G2,Sample 74,None,25.65,-,Positive,Unchecked,Unknown,-,25.65,0,-,-,,SYBR Green I, ,1.11,4.1,None,,,74 76 | 2,155;67;123;181,G3,Sample 75,None,31.18,-,Positive,Unchecked,Unknown,-,31.18,0,-,-,,SYBR Green I, ,0.6,2.73,None,,,75 77 | 2,155;67;123;181,G4,Sample 76,None,29.33,-,Positive,Unchecked,Unknown,-,29.33,0,-,-,,SYBR Green I, ,0.89,3.43,None,,,76 78 | 2,155;67;123;181,G5,Sample 77,None,31.52,-,Positive,Unchecked,Unknown,-,31.52,0,-,-,,SYBR Green I, ,1.16,4.24,None,,,77 79 | 2,155;67;123;181,G6,Sample 78,None,31.15,-,Positive,Unchecked,Unknown,-,31.15,0,-,-,,SYBR Green I, ,1.13,4.01,None,,,78 80 | 2,155;67;123;181,G7,Sample 79,None,27.02,-,Positive,Unchecked,Unknown,-,27.02,0,-,-,,SYBR Green I, ,0.72,3.26,None,,,79 81 | 2,155;67;123;181,G8,Sample 80,None,24.54,-,Positive,Unchecked,Unknown,-,24.54,0,-,-,,SYBR Green I, ,1.1,4.15,None,,,80 82 | 2,155;67;123;181,G9,Sample 81,None,28.38,-,Positive,Unchecked,Unknown,-,28.38,0,-,-,,SYBR Green I, ,0.55,2.8,None,,,81 83 | 2,155;67;123;181,G10,Sample 82,None,28.92,-,Positive,Unchecked,Unknown,-,28.92,0,-,-,,SYBR Green I, ,0.82,3.25,None,,,82 84 | 2,155;67;123;181,G11,Sample 83,None,30.48,-,Positive,Unchecked,Unknown,-,30.48,0,-,-,,SYBR Green I, ,1.18,4.05,None,,,83 85 | 2,155;67;123;181,G12,Sample 84,None,31.8,-,Positive,Unchecked,Unknown,-,31.8,0,-,-,,SYBR Green I, ,1.17,4.06,None,,,84 86 | 2,155;67;123;181,H1,Sample 85,None,28.2,-,Positive,Unchecked,Unknown,-,28.2,0,-,-,,SYBR Green I, ,0.8,3.43,None,,,85 87 | 2,155;67;123;181,H2,Sample 86,None,25.44,-,Positive,Unchecked,Unknown,-,25.44,0,-,-,,SYBR Green I, ,1.19,4.26,None,,,86 88 | 2,155;67;123;181,H3,Sample 87,None,31.09,-,Positive,Unchecked,Unknown,-,31.09,0,-,-,,SYBR Green I, ,0.65,2.89,None,,,87 89 | 2,155;67;123;181,H4,Sample 88,None,28.77,-,Positive,Unchecked,Unknown,-,28.77,0,-,-,,SYBR Green I, ,0.8,3.21,None,,,88 90 | 2,155;67;123;181,H5,Sample 89,None,30.6,-,Positive,Unchecked,Unknown,-,30.6,0,-,-,,SYBR Green I, ,1.27,4.31,None,,,89 91 | 2,155;67;123;181,H6,Sample 90,None,31.15,-,Positive,Unchecked,Unknown,-,31.15,0,-,-,,SYBR Green I, ,1.22,4.17,None,,,90 92 | 2,155;67;123;181,H7,Sample 91,None,26.85,-,Positive,Unchecked,Unknown,-,26.85,0,-,-,,SYBR Green I, ,0.55,2.73,None,,,91 93 | 2,155;67;123;181,H8,Sample 92,None,24.33,-,Positive,Unchecked,Unknown,-,24.33,0,-,-,,SYBR Green I, ,1.21,4.32,None,,,92 94 | 2,155;67;123;181,H9,Sample 93,None,29.11,-,Positive,Unchecked,Unknown,-,29.11,0,-,-,,SYBR Green I, ,0.58,2.9,None,,,93 95 | 2,155;67;123;181,H10,Sample 94,None,28.6,-,Positive,Unchecked,Unknown,-,28.6,0,-,-,,SYBR Green I, ,0.73,3.11,None,,,94 96 | 2,155;67;123;181,H11,Sample 95,None,30.79,-,Positive,Unchecked,Unknown,-,30.79,0,-,-,,SYBR Green I, ,1.23,4.15,None,,,95 97 | 2,155;67;123;181,H12,Sample 96,None,31.88,-,Positive,Unchecked,Unknown,-,31.88,0,-,-,,SYBR Green I, ,1.06,3.88,None,,,96 98 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/inst/examples/cal.exp.curve.cq.csv: -------------------------------------------------------------------------------- 1 | Batch,Color,Position,Sample Name,Gene Name,Cq,Concentration,Call,Excluded,Sample Type,Standard,Cq Mean,Cq Error,Concentration Mean,Concentration Error,Replicate Group,Dye,Edited Call,Slope,EPF,Failure,Notes,Sample Prep Notes,Number 2 | 2,155;67;123;181,A1,Sample 1,None,27.83,-,Positive,Unchecked,Unknown,-,27.83,0,-,-,3,155;67;123;182,A2,Sample 2,None,28.83,-,Positive,Unchecked 3 | 2,155;67;123;181,A2,Sample 2,None,25.81,-,Positive,Unchecked,Unknown,-,25.81,0,-,-,,SYBR Green I, ,1.14,4.17,None,,,2 4 | 2,155;67;123;181,A3,Sample 3,None,34.97,-,Positive,Unchecked,Unknown,-,34.97,0,-,-,,SYBR Green I, ,0.61,2.39,None,,,3 5 | 2,155;67;123;181,A4,Sample 4,None,29.15,-,Positive,Unchecked,Unknown,-,29.15,0,-,-,,SYBR Green I, ,0.89,3.42,None,,,4 6 | 2,155;67;123;181,A5,Sample 5,None,31.96,-,Positive,Unchecked,Unknown,-,31.96,0,-,-,,SYBR Green I, ,1.19,4.11,None,,,5 7 | 2,155;67;123;181,A6,Sample 6,None,33.31,-,Positive,Unchecked,Unknown,-,33.31,0,-,-,,SYBR Green I, ,1.07,3.88,None,,,6 8 | 2,155;67;123;181,A7,Sample 7,None,28.97,-,Positive,Unchecked,Unknown,-,28.97,0,-,-,,SYBR Green I, ,0.69,3.1,None,,,7 9 | 2,155;67;123;181,A8,Sample 8,None,26.47,-,Positive,Unchecked,Unknown,-,26.47,0,-,-,,SYBR Green I, ,1.23,4.32,None,,,8 10 | 2,155;67;123;181,A9,Sample 9,None,31.89,-,Positive,Unchecked,Unknown,-,31.89,0,-,-,,SYBR Green I, ,0.59,2.65,None,,,9 11 | 2,155;67;123;181,A10,Sample 10,None,30.01,-,Positive,Unchecked,Unknown,-,30.01,0,-,-,,SYBR Green I, ,0.91,3.42,None,,,10 12 | 2,155;67;123;181,A11,Sample 11,None,34.94,-,Positive,Unchecked,Unknown,-,34.94,0,-,-,,SYBR Green I, ,1.21,4.19,None,,,11 13 | 2,155;67;123;181,A12,Sample 12,None,33.89,-,Positive,Unchecked,Unknown,-,33.89,0,-,-,,SYBR Green I, ,1.19,4.03,None,,,12 14 | 2,155;67;123;181,B1,Sample 13,None,27.57,-,Positive,Unchecked,Unknown,-,27.57,0,-,-,,SYBR Green I, ,0.81,3.49,None,,,13 15 | 2,155;67;123;181,B2,Sample 14,None,25.79,-,Positive,Unchecked,Unknown,-,25.79,0,-,-,,SYBR Green I, ,1,3.85,None,,,14 16 | 2,155;67;123;181,B3,Sample 15,None,32.04,-,Positive,Unchecked,Unknown,-,32.04,0,-,-,,SYBR Green I, ,0.58,2.57,None,,,15 17 | 2,155;67;123;181,B4,Sample 16,None,29.21,-,Positive,Unchecked,Unknown,-,29.21,0,-,-,,SYBR Green I, ,0.87,3.39,None,,,16 18 | 2,155;67;123;181,B5,Sample 17,None,33,-,Positive,Unchecked,Unknown,-,33,0,-,-,,SYBR Green I, ,1.09,4.15,None,,,17 19 | 2,155;67;123;181,B6,Sample 18,None,33.75,-,Positive,Unchecked,Unknown,-,33.75,0,-,-,,SYBR Green I, ,1.11,3.89,None,,,18 20 | 2,155;67;123;181,B7,Sample 19,None,29.02,-,Positive,Unchecked,Unknown,-,29.02,0,-,-,,SYBR Green I, ,0.71,3.16,None,,,19 21 | 2,155;67;123;181,B8,Sample 20,None,26.48,-,Positive,Unchecked,Unknown,-,26.48,0,-,-,,SYBR Green I, ,1.25,4.37,None,,,20 22 | 2,155;67;123;181,B9,Sample 21,None,30.91,-,Positive,Unchecked,Unknown,-,30.91,0,-,-,,SYBR Green I, ,0.65,2.93,None,,,21 23 | 2,155;67;123;181,B10,Sample 22,None,29.96,-,Positive,Unchecked,Unknown,-,29.96,0,-,-,,SYBR Green I, ,0.89,3.43,None,,,22 24 | 2,155;67;123;181,B11,Sample 23,None,33.76,-,Positive,Unchecked,Unknown,-,33.76,0,-,-,,SYBR Green I, ,1.18,4.19,None,,,23 25 | 2,155;67;123;181,B12,Sample 24,None,35.68,-,Positive,Unchecked,Unknown,-,35.68,0,-,-,,SYBR Green I, ,1.14,3.92,None,,,24 26 | 2,155;67;123;181,C1,Sample 25,None,27.53,-,Positive,Unchecked,Unknown,-,27.53,0,-,-,,SYBR Green I, ,0.75,3.36,None,,,25 27 | 2,155;67;123;181,C2,Sample 26,None,25.48,-,Positive,Unchecked,Unknown,-,25.48,0,-,-,,SYBR Green I, ,1.14,4.17,None,,,26 28 | 2,155;67;123;181,C3,Sample 27,None,32.29,-,Positive,Unchecked,Unknown,-,32.29,0,-,-,,SYBR Green I, ,0.59,2.56,None,,,27 29 | 2,155;67;123;181,C4,Sample 28,None,28.91,-,Positive,Unchecked,Unknown,-,28.91,0,-,-,,SYBR Green I, ,0.86,3.37,None,,,28 30 | 2,155;67;123;181,C5,Sample 29,None,34.54,-,Positive,Unchecked,Unknown,-,34.54,0,-,-,,SYBR Green I, ,1.04,3.93,None,,,29 31 | 2,155;67;123;181,C6,Sample 30,None,31.18,-,Positive,Unchecked,Unknown,-,31.18,0,-,-,,SYBR Green I, ,0.97,3.67,None,,,30 32 | 2,155;67;123;181,C7,Sample 31,None,27.02,-,Positive,Unchecked,Unknown,-,27.02,0,-,-,,SYBR Green I, ,0.65,3.07,None,,,31 33 | 2,155;67;123;181,C8,Sample 32,None,24.15,-,Positive,Unchecked,Unknown,-,24.15,0,-,-,,SYBR Green I, ,0.94,3.8,None,,,32 34 | 2,155;67;123;181,C9,Sample 33,None,29.19,-,Positive,Unchecked,Unknown,-,29.19,0,-,-,,SYBR Green I, ,0.54,2.79,None,,,33 35 | 2,155;67;123;181,C10,Sample 34,None,27.76,-,Positive,Unchecked,Unknown,-,27.76,0,-,-,,SYBR Green I, ,0.75,3.12,None,,,34 36 | 2,155;67;123;181,C11,Sample 35,None,29.6,-,Positive,Unchecked,Unknown,-,29.6,0,-,-,,SYBR Green I, ,1.18,4.01,None,,,35 37 | 2,155;67;123;181,C12,Sample 36,None,31.59,-,Positive,Unchecked,Unknown,-,31.59,0,-,-,,SYBR Green I, ,1.18,4.08,None,,,36 38 | 2,155;67;123;181,D1,Sample 37,None,27.3,-,Positive,Unchecked,Unknown,-,27.3,0,-,-,,SYBR Green I, ,0.85,3.61,None,,,37 39 | 2,155;67;123;181,D2,Sample 38,None,25.4,-,Positive,Unchecked,Unknown,-,25.4,0,-,-,,SYBR Green I, ,1.21,4.32,None,,,38 40 | 2,155;67;123;181,D3,Sample 39,None,31.22,-,Positive,Unchecked,Unknown,-,31.22,0,-,-,,SYBR Green I, ,0.64,2.85,None,,,39 41 | 2,155;67;123;181,D4,Sample 40,None,28.66,-,Positive,Unchecked,Unknown,-,28.66,0,-,-,,SYBR Green I, ,0.89,3.45,None,,,40 42 | 2,155;67;123;181,D5,Sample 41,None,32.07,-,Positive,Unchecked,Unknown,-,32.07,0,-,-,,SYBR Green I, ,1.35,4.38,None,,,41 43 | 2,155;67;123;181,D6,Sample 42,None,31.21,-,Positive,Unchecked,Unknown,-,31.21,0,-,-,,SYBR Green I, ,1.17,4.12,None,,,42 44 | 2,155;67;123;181,D7,Sample 43,None,27.25,-,Positive,Unchecked,Unknown,-,27.25,0,-,-,,SYBR Green I, ,0.77,3.42,None,,,43 45 | 2,155;67;123;181,D8,Sample 44,None,23.99,-,Positive,Unchecked,Unknown,-,23.99,0,-,-,,SYBR Green I, ,1.12,4.19,None,,,44 46 | 2,155;67;123;181,D9,Sample 45,None,29.37,-,Positive,Unchecked,Unknown,-,29.37,0,-,-,,SYBR Green I, ,0.64,3.06,None,,,45 47 | 2,155;67;123;181,D10,Sample 46,None,27.59,-,Positive,Unchecked,Unknown,-,27.59,0,-,-,,SYBR Green I, ,0.86,3.42,None,,,46 48 | 2,155;67;123;181,D11,Sample 47,None,30.53,-,Positive,Unchecked,Unknown,-,30.53,0,-,-,,SYBR Green I, ,1.28,4.25,None,,,47 49 | 2,155;67;123;181,D12,Sample 48,None,32,-,Positive,Unchecked,Unknown,-,32,0,-,-,,SYBR Green I, ,1.16,4.06,None,,,48 50 | 2,155;67;123;181,E1,Sample 49,None,28.13,-,Positive,Unchecked,Unknown,-,28.13,0,-,-,,SYBR Green I, ,0.83,3.49,None,,,49 51 | 2,155;67;123;181,E2,Sample 50,None,25.6,-,Positive,Unchecked,Unknown,-,25.6,0,-,-,,SYBR Green I, ,1.29,4.47,None,,,50 52 | 2,155;67;123;181,E3,Sample 51,None,30.63,-,Positive,Unchecked,Unknown,-,30.63,0,-,-,,SYBR Green I, ,0.64,2.91,None,,,51 53 | 2,155;67;123;181,E4,Sample 52,None,28.75,-,Positive,Unchecked,Unknown,-,28.75,0,-,-,,SYBR Green I, ,0.87,3.4,None,,,52 54 | 2,155;67;123;181,E5,Sample 53,None,32.45,-,Positive,Unchecked,Unknown,-,32.45,0,-,-,,SYBR Green I, ,1.14,4.15,None,,,53 55 | 2,155;67;123;181,E6,Sample 54,None,34.44,-,Positive,Unchecked,Unknown,-,34.44,0,-,-,,SYBR Green I, ,0.95,3.56,None,,,54 56 | 2,155;67;123;181,E7,Sample 55,None,27.94,-,Positive,Unchecked,Unknown,-,27.94,0,-,-,,SYBR Green I, ,0.67,3.09,None,,,55 57 | 2,155;67;123;181,E8,Sample 56,None,25.12,-,Positive,Unchecked,Unknown,-,25.12,0,-,-,,SYBR Green I, ,0.85,3.53,None,,,56 58 | 2,155;67;123;181,E9,Sample 57,None,29.36,-,Positive,Unchecked,Unknown,-,29.36,0,-,-,,SYBR Green I, ,0.56,2.83,None,,,57 59 | 2,155;67;123;181,E10,Sample 58,None,28.39,-,Positive,Unchecked,Unknown,-,28.39,0,-,-,,SYBR Green I, ,0.87,3.41,None,,,58 60 | 2,155;67;123;181,E11,Sample 59,None,32.08,-,Positive,Unchecked,Unknown,-,32.08,0,-,-,,SYBR Green I, ,1.18,4.22,None,,,59 61 | 2,155;67;123;181,E12,Sample 60,None,34.67,-,Positive,Unchecked,Unknown,-,34.67,0,-,-,,SYBR Green I, ,1.15,4.06,None,,,60 62 | 2,155;67;123;181,F1,Sample 61,None,27.87,-,Positive,Unchecked,Unknown,-,27.87,0,-,-,,SYBR Green I, ,0.83,3.51,None,,,61 63 | 2,155;67;123;181,F2,Sample 62,None,26.13,-,Positive,Unchecked,Unknown,-,26.13,0,-,-,,SYBR Green I, ,0.99,3.86,None,,,62 64 | 2,155;67;123;181,F3,Sample 63,None,31.37,-,Positive,Unchecked,Unknown,-,31.37,0,-,-,,SYBR Green I, ,0.55,2.55,None,,,63 65 | 2,155;67;123;181,F4,Sample 64,None,28.96,-,Positive,Unchecked,Unknown,-,28.96,0,-,-,,SYBR Green I, ,0.91,3.48,None,,,64 66 | 2,155;67;123;181,F5,Sample 65,None,32.91,-,Positive,Unchecked,Unknown,-,32.91,0,-,-,,SYBR Green I, ,1.15,4.1,None,,,65 67 | 2,155;67;123;181,F6,Sample 66,None,33.46,-,Positive,Unchecked,Unknown,-,33.46,0,-,-,,SYBR Green I, ,1.14,4.02,None,,,66 68 | 2,155;67;123;181,F7,Sample 67,None,27.49,-,Positive,Unchecked,Unknown,-,27.49,0,-,-,,SYBR Green I, ,0.72,3.25,None,,,67 69 | 2,155;67;123;181,F8,Sample 68,None,25.03,-,Positive,Unchecked,Unknown,-,25.03,0,-,-,,SYBR Green I, ,1.12,4.14,None,,,68 70 | 2,155;67;123;181,F9,Sample 69,None,30,-,Positive,Unchecked,Unknown,-,30,0,-,-,,SYBR Green I, ,0.43,2.33,None,,,69 71 | 2,155;67;123;181,F10,Sample 70,None,28.57,-,Positive,Unchecked,Unknown,-,28.57,0,-,-,,SYBR Green I, ,0.81,3.23,None,,,70 72 | 2,155;67;123;181,F11,Sample 71,None,31.87,-,Positive,Unchecked,Unknown,-,31.87,0,-,-,,SYBR Green I, ,1.08,4.05,None,,,71 73 | 2,155;67;123;181,F12,Sample 72,None,32.98,-,Positive,Unchecked,Unknown,-,32.98,0,-,-,,SYBR Green I, ,1.07,3.84,None,,,72 74 | 2,155;67;123;181,G1,Sample 73,None,27.97,-,Positive,Unchecked,Unknown,-,27.97,0,-,-,,SYBR Green I, ,0.83,3.54,None,,,73 75 | 2,155;67;123;181,G2,Sample 74,None,25.65,-,Positive,Unchecked,Unknown,-,25.65,0,-,-,,SYBR Green I, ,1.11,4.1,None,,,74 76 | 2,155;67;123;181,G3,Sample 75,None,31.18,-,Positive,Unchecked,Unknown,-,31.18,0,-,-,,SYBR Green I, ,0.6,2.73,None,,,75 77 | 2,155;67;123;181,G4,Sample 76,None,29.33,-,Positive,Unchecked,Unknown,-,29.33,0,-,-,,SYBR Green I, ,0.89,3.43,None,,,76 78 | 2,155;67;123;181,G5,Sample 77,None,31.52,-,Positive,Unchecked,Unknown,-,31.52,0,-,-,,SYBR Green I, ,1.16,4.24,None,,,77 79 | 2,155;67;123;181,G6,Sample 78,None,31.15,-,Positive,Unchecked,Unknown,-,31.15,0,-,-,,SYBR Green I, ,1.13,4.01,None,,,78 80 | 2,155;67;123;181,G7,Sample 79,None,27.02,-,Positive,Unchecked,Unknown,-,27.02,0,-,-,,SYBR Green I, ,0.72,3.26,None,,,79 81 | 2,155;67;123;181,G8,Sample 80,None,24.54,-,Positive,Unchecked,Unknown,-,24.54,0,-,-,,SYBR Green I, ,1.1,4.15,None,,,80 82 | 2,155;67;123;181,G9,Sample 81,None,28.38,-,Positive,Unchecked,Unknown,-,28.38,0,-,-,,SYBR Green I, ,0.55,2.8,None,,,81 83 | 2,155;67;123;181,G10,Sample 82,None,28.92,-,Positive,Unchecked,Unknown,-,28.92,0,-,-,,SYBR Green I, ,0.82,3.25,None,,,82 84 | 2,155;67;123;181,G11,Sample 83,None,30.48,-,Positive,Unchecked,Unknown,-,30.48,0,-,-,,SYBR Green I, ,1.18,4.05,None,,,83 85 | 2,155;67;123;181,G12,Sample 84,None,31.8,-,Positive,Unchecked,Unknown,-,31.8,0,-,-,,SYBR Green I, ,1.17,4.06,None,,,84 86 | 2,155;67;123;181,H1,Sample 85,None,28.2,-,Positive,Unchecked,Unknown,-,28.2,0,-,-,,SYBR Green I, ,0.8,3.43,None,,,85 87 | 2,155;67;123;181,H2,Sample 86,None,25.44,-,Positive,Unchecked,Unknown,-,25.44,0,-,-,,SYBR Green I, ,1.19,4.26,None,,,86 88 | 2,155;67;123;181,H3,Sample 87,None,31.09,-,Positive,Unchecked,Unknown,-,31.09,0,-,-,,SYBR Green I, ,0.65,2.89,None,,,87 89 | 2,155;67;123;181,H4,Sample 88,None,28.77,-,Positive,Unchecked,Unknown,-,28.77,0,-,-,,SYBR Green I, ,0.8,3.21,None,,,88 90 | 2,155;67;123;181,H5,Sample 89,None,30.6,-,Positive,Unchecked,Unknown,-,30.6,0,-,-,,SYBR Green I, ,1.27,4.31,None,,,89 91 | 2,155;67;123;181,H6,Sample 90,None,31.15,-,Positive,Unchecked,Unknown,-,31.15,0,-,-,,SYBR Green I, ,1.22,4.17,None,,,90 92 | 2,155;67;123;181,H7,Sample 91,None,26.85,-,Positive,Unchecked,Unknown,-,26.85,0,-,-,,SYBR Green I, ,0.55,2.73,None,,,91 93 | 2,155;67;123;181,H8,Sample 92,None,24.33,-,Positive,Unchecked,Unknown,-,24.33,0,-,-,,SYBR Green I, ,1.21,4.32,None,,,92 94 | 2,155;67;123;181,H9,Sample 93,None,29.11,-,Positive,Unchecked,Unknown,-,29.11,0,-,-,,SYBR Green I, ,0.58,2.9,None,,,93 95 | 2,155;67;123;181,H10,Sample 94,None,28.6,-,Positive,Unchecked,Unknown,-,28.6,0,-,-,,SYBR Green I, ,0.73,3.11,None,,,94 96 | 2,155;67;123;181,H11,Sample 95,None,30.79,-,Positive,Unchecked,Unknown,-,30.79,0,-,-,,SYBR Green I, ,1.23,4.15,None,,,95 97 | 2,155;67;123;181,H12,Sample 96,None,31.88,-,Positive,Unchecked,Unknown,-,31.88,0,-,-,,SYBR Green I, ,1.06,3.88,None,,,96 98 | -------------------------------------------------------------------------------- /R/CalExp2ddCt.R: -------------------------------------------------------------------------------- 1 | #' @name CalExp2ddCt 2 | #' @author Xiang LI 3 | #' 4 | #' @title Calculate expression using standard curve. 5 | #' @description Calculate expression using standard curve. 6 | #' 7 | #' @param cq.table The data frame of the position and cq value. 8 | #' @param design.table The data frame of the position and corresponding information. 9 | #' @param correction Correct expression value by reference gene. 10 | #' @param ref.gene The name of reference gene. 11 | #' @param ref.group The name of reference group. 12 | #' @param stat.method Statistical method. 13 | #' @param remove.outliers Remove the outliers of each group and gene, or not. 14 | #' @param fig.type Output image type, `box` represents `boxplot`, `bar` represents `barplot`. 15 | #' @param fig.ncol Number of columes of figure. 16 | #' 17 | #' @export 18 | #' @return A list contain a table and a figure. 19 | #' @examples 20 | #' df1.path = system.file("examples", "ddct.cq.txt", package = "qPCRtools") 21 | #' df2.path = system.file("examples", "ddct.design.txt", package = "qPCRtools") 22 | #' 23 | #' cq.table = read.table(df1.path, header = TRUE) 24 | #' design.table = read.table(df2.path, header = TRUE) 25 | #' 26 | #' CalExp2ddCt(cq.table, 27 | #' design.table, 28 | #' ref.gene = "OsUBQ", 29 | #' ref.group = "CK", 30 | #' stat.method = "t.test", 31 | #' remove.outliers = TRUE, 32 | #' fig.type = "box", 33 | #' fig.ncol = NULL) -> res 34 | #' 35 | #' res[["table"]] 36 | #' res[["figure"]] 37 | #' 38 | globalVariables(c( 39 | "cq.table", 40 | "curve.table", 41 | "design.table", 42 | "correction", 43 | "ref.gene", 44 | "stat.method", 45 | "remove.outliers", 46 | "ref.group", 47 | "fig.type", 48 | "fig.ncol", 49 | "out", 50 | "cq", 51 | "max.cq", 52 | "min.cq", 53 | "expre", 54 | "Intercept", 55 | "Slope", 56 | "Treatment", 57 | "element_text", 58 | "group2", 59 | "max.temp", 60 | "mean.expre", 61 | "mean.ref", 62 | "n", 63 | "sd", 64 | "sd.expre", 65 | "Treatment", 66 | "mean.ref", 67 | "group2", 68 | "temp", 69 | "n", 70 | "sd.expre", 71 | "n", 72 | "mean.expre", 73 | "element_text", 74 | "max.temp", 75 | 'gene', 76 | 'group', 77 | 'biorep', 78 | 'Target', 79 | 'Reference', 80 | 'ddct1', 81 | 'mean.expression', 82 | 'n.biorep', 83 | 'sd.expression', 84 | 'se.expression', 85 | 'Reference', 86 | 'Target', 87 | 'biorep', 88 | 'ddct1', 89 | 'gene', 90 | 'group', 91 | 'mean.expression', 92 | 'n.biorep', 93 | 'sd.expression', 94 | 'se.expression', 95 | 'BioRep', 96 | 'Eff', 97 | 'Group', 98 | 'TechRep', 99 | 'rr.label', 100 | 'p.value.label', 101 | 'IQR', 102 | 'quantile', 103 | 'is.out' 104 | 105 | )) 106 | CalExp2ddCt <- function(cq.table, 107 | design.table, 108 | ref.gene = "OsUBQ", 109 | ref.group = "CK", 110 | stat.method = "t.test", 111 | remove.outliers = TRUE, 112 | fig.type = "box", 113 | fig.ncol = NULL) { 114 | 115 | # res 116 | res.all <- NULL 117 | 118 | # merge data 119 | cq.table %>% 120 | dplyr::left_join(design.table, by = "Position") %>% 121 | dplyr::rename(position = Position, 122 | cq = Cq, 123 | group = Group, 124 | gene = Gene, 125 | biorep = BioRep) -> df 126 | 127 | # for each gene 128 | target.genes <- setdiff(unique(df$gene), ref.gene) 129 | 130 | for (genes in target.genes) { 131 | df.sub <- df %>% 132 | dplyr::filter(gene %in% c(genes, ref.gene)) 133 | 134 | df.sub.ck <- df.sub %>% 135 | dplyr::filter(group == ref.group) 136 | 137 | # reference gene in CK 138 | df.sub.ck.ref.gene <- df.sub %>% 139 | dplyr::filter(gene == ref.gene) 140 | mean.ck.ref.gene <- mean(df.sub.ck.ref.gene$cq) 141 | 142 | df.sub.ck.target.gene <- df.sub %>% 143 | dplyr::filter(gene != ref.gene) 144 | mean.ck.target.gene <- mean(df.sub.ck.target.gene$cq) 145 | 146 | dct1 <- mean.ck.target.gene - mean.ck.ref.gene 147 | 148 | # for each treatment 149 | for (groups in unique(df.sub$group)) { 150 | df.sub.group <- df.sub %>% 151 | dplyr::filter(group == groups) %>% 152 | dplyr::select(biorep, gene, cq) %>% 153 | dplyr::group_by(gene, biorep) %>% 154 | dplyr::mutate(cq = mean(cq)) %>% 155 | dplyr::ungroup() %>% 156 | dplyr::distinct_all() %>% 157 | tidyr::pivot_wider(id_cols = "biorep", names_from = "gene", values_from = "cq") %>% 158 | dplyr::mutate(dct1 = dct1) 159 | # including ref gene or not 160 | if (ncol(df.sub.group) == 3 & !genes %in% colnames(df.sub.group)) { 161 | stop(paste0("Data of target gene ", genes, " has some problem, please check it and try again!")) 162 | } 163 | if (colnames(df.sub.group)[3] == ref.gene) { 164 | df.sub.group %>% 165 | magrittr::set_names(c("biorep", "Target", "Reference", "ddct1")) %>% 166 | dplyr::mutate(expression = 2^(-(Target - Reference - ddct1))) %>% 167 | dplyr::mutate( 168 | group = groups, 169 | gene = genes 170 | ) %>% 171 | dplyr::select(group, gene, biorep, expression) %>% 172 | rbind(res.all) -> res.all 173 | } else { 174 | df.sub.group %>% 175 | dplyr::select(1, 3, 2, 4) %>% 176 | magrittr::set_names(c("biorep", "Target", "Reference", "ddct1")) %>% 177 | dplyr::mutate(expression = 2^(-(Target - Reference - ddct1))) %>% 178 | dplyr::mutate( 179 | group = groups, 180 | gene = genes 181 | ) %>% 182 | dplyr::select(group, gene, biorep, expression) %>% 183 | rbind(res.all) -> res.all 184 | } 185 | } 186 | } 187 | 188 | # find outliner function 189 | findoutliner <- function(x) { 190 | return( 191 | ifelse( 192 | x < quantile(x, .25) - 1.5 * IQR(x) | x > quantile(x, .75) + 1.5 * IQR(x), 193 | "yes", 194 | "no" 195 | ) 196 | ) 197 | } 198 | 199 | if (remove.outliers) { 200 | res.all %>% 201 | dplyr::group_by(group, gene) %>% 202 | dplyr::mutate(is.out = findoutliner(expression)) %>% 203 | dplyr::ungroup() %>% 204 | dplyr::filter(is.out == "no") -> res.all 205 | }else{ 206 | res.all -> res.all 207 | } 208 | 209 | # group and mean and sd 210 | res.all %>% 211 | dplyr::group_by(group, gene) %>% 212 | dplyr::mutate( 213 | mean.expression = mean(expression), 214 | sd.expression = stats::sd(expression), 215 | n.biorep = dplyr::n(), 216 | se.expression = mean.expression / sqrt(n.biorep) 217 | ) %>% 218 | dplyr::ungroup() %>% 219 | dplyr::mutate(temp = paste0(gene, group)) -> res.all 220 | 221 | # statistics 222 | if (stat.method == "t.test") { 223 | res.all %>% 224 | dplyr::group_by(gene) %>% 225 | rstatix::t_test(expression ~ group, ref.group = ref.group) %>% 226 | dplyr::ungroup() %>% 227 | dplyr::select(gene, group2, p) %>% 228 | dplyr::mutate(signif = dplyr::case_when( 229 | p < 0.001 ~ "***", 230 | p > 0.001 & p < 0.01 ~ "**", 231 | p > 0.01 & p < 0.05 ~ "*", 232 | TRUE ~ "NS" 233 | )) %>% 234 | dplyr::add_row(group2 = ref.group, p = NA, signif = NA) %>% 235 | dplyr::rename(group = group2) %>% 236 | dplyr::mutate(temp = paste0(gene, group)) %>% 237 | dplyr::select(temp, signif) -> df.stat 238 | 239 | res.all <- res.all %>% 240 | dplyr::left_join(df.stat, by = "temp") 241 | } else if (stat.method == "wilcox.test") { 242 | res.all %>% 243 | dplyr::group_by(gene) %>% 244 | rstatix::wilcox_test(expression ~ group, ref.group = ref.group) %>% 245 | dplyr::ungroup() %>% 246 | dplyr::select(gene, group2, p) %>% 247 | dplyr::mutate(signif = dplyr::case_when( 248 | p < 0.001 ~ "***", 249 | p > 0.001 & p < 0.01 ~ "**", 250 | p > 0.01 & p < 0.05 ~ "*", 251 | TRUE ~ "NS" 252 | )) %>% 253 | dplyr::add_row(group2 = ref.group, p = NA, signif = NA) %>% 254 | dplyr::rename(group = group2) %>% 255 | dplyr::mutate(temp = paste0(gene, group)) %>% 256 | dplyr::select(temp, signif) -> df.stat 257 | 258 | res.all <- res.all %>% 259 | dplyr::left_join(df.stat, by = "temp") 260 | } else { 261 | df.stat <- NULL 262 | for (i in unique(res.all$gene)) { 263 | df.sub <- res.all %>% 264 | dplyr::filter(gene == i) %>% 265 | dplyr::mutate(group = factor(group)) 266 | fit <- stats::aov(expression ~ group, data = df.sub) 267 | tuk <- multcomp::glht(fit, linfct = multcomp::mcp(group = "Tukey")) 268 | multcomp::cld(tuk, level = 0.95, ddecreasing = TRUE)[["mcletters"]][["Letters"]] %>% 269 | as.data.frame() %>% 270 | dplyr::mutate(gene = i) %>% 271 | tibble::rownames_to_column(var = "group") %>% 272 | magrittr::set_colnames(c("group", "signif", "gene")) %>% 273 | dplyr::select(group, gene, signif) %>% 274 | dplyr::mutate(temp = paste0(group, gene)) %>% 275 | dplyr::select(temp, signif) %>% 276 | rbind(df.stat) -> df.stat 277 | } 278 | res.all %>% 279 | dplyr::mutate(temp = paste0(group, gene)) %>% 280 | dplyr::left_join(df.stat, by = "temp") -> res.all 281 | } 282 | 283 | # plot 284 | df.plot <- res.all %>% 285 | dplyr::rename( 286 | Treatment = group, 287 | gene = gene, 288 | expre = expression, 289 | mean.expre = mean.expression, 290 | sd.expre = sd.expression, 291 | se.expre = se.expression, 292 | n = n.biorep 293 | ) 294 | 295 | 296 | if (fig.type == "box") { 297 | df.plot %>% 298 | ggplot2::ggplot(ggplot2::aes(Treatment, expre, fill = Treatment)) + 299 | ggplot2::geom_boxplot(width = 0.6) + 300 | ggplot2::facet_wrap(. ~ gene, scales = "free_y", ncol = fig.ncol) + 301 | ggplot2::geom_text(ggplot2::aes(Treatment, mean.expre, label = "."), 302 | check_overlap = TRUE, size = 15, color = "red" 303 | ) + 304 | ggplot2::geom_text(ggplot2::aes(Treatment, min(expre), label = signif), 305 | check_overlap = TRUE, size = 3, color = "black" 306 | ) + 307 | ggthemes::theme_pander() + 308 | ggplot2::labs(y = "Relative expression") + 309 | ggplot2::theme( 310 | legend.position = "none", 311 | strip.text.x = ggplot2::element_text(face = "italic") 312 | ) -> p 313 | } else if (fig.type == "bar") { 314 | df.plot %>% 315 | dplyr::group_by(Treatment, gene) %>% 316 | dplyr::mutate(max.temp = max(expre)) %>% 317 | dplyr::ungroup() %>% 318 | ggplot2::ggplot(ggplot2::aes(Treatment, mean.expre / n, fill = Treatment)) + 319 | ggplot2::geom_bar(stat = "identity", width = 0.6) + 320 | ggplot2::geom_errorbar(ggplot2::aes(Treatment, 321 | ymin = mean.expre - sd.expre, 322 | ymax = mean.expre + sd.expre 323 | ), 324 | width = 0.2 325 | ) + 326 | ggplot2::geom_jitter(ggplot2::aes(Treatment, expre), width = 0.1, alpha = 0.4) + 327 | ggplot2::geom_hline(ggplot2::aes(yintercept = max.temp * 1.1), color = NA) + 328 | ggplot2::facet_wrap(. ~ gene, scales = "free_y", ncol = fig.ncol) + 329 | ggplot2::geom_text(ggplot2::aes(Treatment, max.temp * 1.08, label = signif), 330 | check_overlap = TRUE, size = 4, color = "red" 331 | ) + 332 | ggthemes::theme_pander() + 333 | ggplot2::labs(y = "Relative expression") + 334 | ggplot2::theme( 335 | legend.position = "none", 336 | strip.text.x = ggplot2::element_text(face = "italic") 337 | ) -> p 338 | } 339 | res <- list(table = df.plot, figure = p) 340 | return(res) 341 | } 342 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/R/CalExp2ddCt.R: -------------------------------------------------------------------------------- 1 | #' @name CalExp2ddCt 2 | #' @author Xiang LI 3 | #' 4 | #' @title Calculate expression using standard curve. 5 | #' @description Calculate expression using standard curve. 6 | #' 7 | #' @param cq.table The data frame of the position and cq value. 8 | #' @param design.table The data frame of the position and corresponding information. 9 | #' @param correction Correct expression value by reference gene. 10 | #' @param ref.gene The name of reference gene. 11 | #' @param ref.group The name of reference group. 12 | #' @param stat.method Statistical method. 13 | #' @param remove.outliers Remove the outliers of each group and gene, or not. 14 | #' @param fig.type Output image type, `box` represents `boxplot`, `bar` represents `barplot`. 15 | #' @param fig.ncol Number of columes of figure. 16 | #' 17 | #' @export 18 | #' @return A list contain a table and a figure. 19 | #' @examples 20 | #' df1.path = system.file("examples", "ddct.cq.txt", package = "qPCRtools") 21 | #' df2.path = system.file("examples", "ddct.design.txt", package = "qPCRtools") 22 | #' 23 | #' cq.table = read.table(df1.path, header = TRUE) 24 | #' design.table = read.table(df2.path, header = TRUE) 25 | #' 26 | #' CalExp2ddCt(cq.table, 27 | #' design.table, 28 | #' ref.gene = "OsUBQ", 29 | #' ref.group = "CK", 30 | #' stat.method = "t.test", 31 | #' remove.outliers = TRUE, 32 | #' fig.type = "box", 33 | #' fig.ncol = NULL) -> res 34 | #' 35 | #' res[["table"]] 36 | #' res[["figure"]] 37 | #' 38 | globalVariables(c( 39 | "cq.table", 40 | "curve.table", 41 | "design.table", 42 | "correction", 43 | "ref.gene", 44 | "stat.method", 45 | "remove.outliers", 46 | "ref.group", 47 | "fig.type", 48 | "fig.ncol", 49 | "out", 50 | "cq", 51 | "max.cq", 52 | "min.cq", 53 | "expre", 54 | "Intercept", 55 | "Slope", 56 | "Treatment", 57 | "element_text", 58 | "group2", 59 | "max.temp", 60 | "mean.expre", 61 | "mean.ref", 62 | "n", 63 | "sd", 64 | "sd.expre", 65 | "Treatment", 66 | "mean.ref", 67 | "group2", 68 | "temp", 69 | "n", 70 | "sd.expre", 71 | "n", 72 | "mean.expre", 73 | "element_text", 74 | "max.temp", 75 | 'gene', 76 | 'group', 77 | 'biorep', 78 | 'Target', 79 | 'Reference', 80 | 'ddct1', 81 | 'mean.expression', 82 | 'n.biorep', 83 | 'sd.expression', 84 | 'se.expression', 85 | 'Reference', 86 | 'Target', 87 | 'biorep', 88 | 'ddct1', 89 | 'gene', 90 | 'group', 91 | 'mean.expression', 92 | 'n.biorep', 93 | 'sd.expression', 94 | 'se.expression', 95 | 'BioRep', 96 | 'Eff', 97 | 'Group', 98 | 'TechRep', 99 | 'rr.label', 100 | 'p.value.label', 101 | 'IQR', 102 | 'quantile', 103 | 'is.out' 104 | 105 | )) 106 | CalExp2ddCt <- function(cq.table, 107 | design.table, 108 | ref.gene = "OsUBQ", 109 | ref.group = "CK", 110 | stat.method = "t.test", 111 | remove.outliers = TRUE, 112 | fig.type = "box", 113 | fig.ncol = NULL) { 114 | 115 | # res 116 | res.all <- NULL 117 | 118 | # merge data 119 | cq.table %>% 120 | dplyr::left_join(design.table, by = "Position") %>% 121 | dplyr::rename(position = Position, 122 | cq = Cq, 123 | group = Group, 124 | gene = Gene, 125 | biorep = BioRep) -> df 126 | 127 | # for each gene 128 | target.genes <- setdiff(unique(df$gene), ref.gene) 129 | 130 | for (genes in target.genes) { 131 | df.sub <- df %>% 132 | dplyr::filter(gene %in% c(genes, ref.gene)) 133 | 134 | df.sub.ck <- df.sub %>% 135 | dplyr::filter(group == ref.group) 136 | 137 | # reference gene in CK 138 | df.sub.ck.ref.gene <- df.sub %>% 139 | dplyr::filter(gene == ref.gene) 140 | mean.ck.ref.gene <- mean(df.sub.ck.ref.gene$cq) 141 | 142 | df.sub.ck.target.gene <- df.sub %>% 143 | dplyr::filter(gene != ref.gene) 144 | mean.ck.target.gene <- mean(df.sub.ck.target.gene$cq) 145 | 146 | dct1 <- mean.ck.target.gene - mean.ck.ref.gene 147 | 148 | # for each treatment 149 | for (groups in unique(df.sub$group)) { 150 | df.sub.group <- df.sub %>% 151 | dplyr::filter(group == groups) %>% 152 | dplyr::select(biorep, gene, cq) %>% 153 | dplyr::group_by(gene, biorep) %>% 154 | dplyr::mutate(cq = mean(cq)) %>% 155 | dplyr::ungroup() %>% 156 | dplyr::distinct_all() %>% 157 | tidyr::pivot_wider(id_cols = "biorep", names_from = "gene", values_from = "cq") %>% 158 | dplyr::mutate(dct1 = dct1) 159 | # including ref gene or not 160 | if (ncol(df.sub.group) == 3 & !genes %in% colnames(df.sub.group)) { 161 | stop(paste0("Data of target gene ", genes, " has some problem, please check it and try again!")) 162 | } 163 | if (colnames(df.sub.group)[3] == ref.gene) { 164 | df.sub.group %>% 165 | magrittr::set_names(c("biorep", "Target", "Reference", "ddct1")) %>% 166 | dplyr::mutate(expression = 2^(-(Target - Reference - ddct1))) %>% 167 | dplyr::mutate( 168 | group = groups, 169 | gene = genes 170 | ) %>% 171 | dplyr::select(group, gene, biorep, expression) %>% 172 | rbind(res.all) -> res.all 173 | } else { 174 | df.sub.group %>% 175 | dplyr::select(1, 3, 2, 4) %>% 176 | magrittr::set_names(c("biorep", "Target", "Reference", "ddct1")) %>% 177 | dplyr::mutate(expression = 2^(-(Target - Reference - ddct1))) %>% 178 | dplyr::mutate( 179 | group = groups, 180 | gene = genes 181 | ) %>% 182 | dplyr::select(group, gene, biorep, expression) %>% 183 | rbind(res.all) -> res.all 184 | } 185 | } 186 | } 187 | 188 | # find outliner function 189 | findoutliner <- function(x) { 190 | return( 191 | ifelse( 192 | x < quantile(x, .25) - 1.5 * IQR(x) | x > quantile(x, .75) + 1.5 * IQR(x), 193 | "yes", 194 | "no" 195 | ) 196 | ) 197 | } 198 | 199 | if (remove.outliers) { 200 | res.all %>% 201 | dplyr::group_by(group, gene) %>% 202 | dplyr::mutate(is.out = findoutliner(expression)) %>% 203 | dplyr::ungroup() %>% 204 | dplyr::filter(is.out == "no") -> res.all 205 | }else{ 206 | res.all -> res.all 207 | } 208 | 209 | # group and mean and sd 210 | res.all %>% 211 | dplyr::group_by(group, gene) %>% 212 | dplyr::mutate( 213 | mean.expression = mean(expression), 214 | sd.expression = stats::sd(expression), 215 | n.biorep = dplyr::n(), 216 | se.expression = mean.expression / sqrt(n.biorep) 217 | ) %>% 218 | dplyr::ungroup() %>% 219 | dplyr::mutate(temp = paste0(gene, group)) -> res.all 220 | 221 | # statistics 222 | if (stat.method == "t.test") { 223 | res.all %>% 224 | dplyr::group_by(gene) %>% 225 | rstatix::t_test(expression ~ group, ref.group = ref.group) %>% 226 | dplyr::ungroup() %>% 227 | dplyr::select(gene, group2, p) %>% 228 | dplyr::mutate(signif = dplyr::case_when( 229 | p < 0.001 ~ "***", 230 | p > 0.001 & p < 0.01 ~ "**", 231 | p > 0.01 & p < 0.05 ~ "*", 232 | TRUE ~ "NS" 233 | )) %>% 234 | dplyr::add_row(group2 = ref.group, p = NA, signif = NA) %>% 235 | dplyr::rename(group = group2) %>% 236 | dplyr::mutate(temp = paste0(gene, group)) %>% 237 | dplyr::select(temp, signif) -> df.stat 238 | 239 | res.all <- res.all %>% 240 | dplyr::left_join(df.stat, by = "temp") 241 | } else if (stat.method == "wilcox.test") { 242 | res.all %>% 243 | dplyr::group_by(gene) %>% 244 | rstatix::wilcox_test(expression ~ group, ref.group = ref.group) %>% 245 | dplyr::ungroup() %>% 246 | dplyr::select(gene, group2, p) %>% 247 | dplyr::mutate(signif = dplyr::case_when( 248 | p < 0.001 ~ "***", 249 | p > 0.001 & p < 0.01 ~ "**", 250 | p > 0.01 & p < 0.05 ~ "*", 251 | TRUE ~ "NS" 252 | )) %>% 253 | dplyr::add_row(group2 = ref.group, p = NA, signif = NA) %>% 254 | dplyr::rename(group = group2) %>% 255 | dplyr::mutate(temp = paste0(gene, group)) %>% 256 | dplyr::select(temp, signif) -> df.stat 257 | 258 | res.all <- res.all %>% 259 | dplyr::left_join(df.stat, by = "temp") 260 | } else { 261 | df.stat <- NULL 262 | for (i in unique(res.all$gene)) { 263 | df.sub <- res.all %>% 264 | dplyr::filter(gene == i) %>% 265 | dplyr::mutate(group = factor(group)) 266 | fit <- stats::aov(expression ~ group, data = df.sub) 267 | tuk <- multcomp::glht(fit, linfct = multcomp::mcp(group = "Tukey")) 268 | multcomp::cld(tuk, level = 0.95, ddecreasing = TRUE)[["mcletters"]][["Letters"]] %>% 269 | as.data.frame() %>% 270 | dplyr::mutate(gene = i) %>% 271 | tibble::rownames_to_column(var = "group") %>% 272 | magrittr::set_colnames(c("group", "signif", "gene")) %>% 273 | dplyr::select(group, gene, signif) %>% 274 | dplyr::mutate(temp = paste0(group, gene)) %>% 275 | dplyr::select(temp, signif) %>% 276 | rbind(df.stat) -> df.stat 277 | } 278 | res.all %>% 279 | dplyr::mutate(temp = paste0(group, gene)) %>% 280 | dplyr::left_join(df.stat, by = "temp") -> res.all 281 | } 282 | 283 | # plot 284 | df.plot <- res.all %>% 285 | dplyr::rename( 286 | Treatment = group, 287 | gene = gene, 288 | expre = expression, 289 | mean.expre = mean.expression, 290 | sd.expre = sd.expression, 291 | se.expre = se.expression, 292 | n = n.biorep 293 | ) 294 | 295 | 296 | if (fig.type == "box") { 297 | df.plot %>% 298 | ggplot2::ggplot(ggplot2::aes(Treatment, expre, fill = Treatment)) + 299 | ggplot2::geom_boxplot(width = 0.6) + 300 | ggplot2::facet_wrap(. ~ gene, scales = "free_y", ncol = fig.ncol) + 301 | ggplot2::geom_text(ggplot2::aes(Treatment, mean.expre, label = "."), 302 | check_overlap = TRUE, size = 15, color = "red" 303 | ) + 304 | ggplot2::geom_text(ggplot2::aes(Treatment, min(expre), label = signif), 305 | check_overlap = TRUE, size = 3, color = "black" 306 | ) + 307 | ggthemes::theme_pander() + 308 | ggplot2::labs(y = "Relative expression") + 309 | ggplot2::theme( 310 | legend.position = "none", 311 | strip.text.x = ggplot2::element_text(face = "italic") 312 | ) -> p 313 | } else if (fig.type == "bar") { 314 | df.plot %>% 315 | dplyr::group_by(Treatment, gene) %>% 316 | dplyr::mutate(max.temp = max(expre)) %>% 317 | dplyr::ungroup() %>% 318 | ggplot2::ggplot(ggplot2::aes(Treatment, mean.expre / n, fill = Treatment)) + 319 | ggplot2::geom_bar(stat = "identity", width = 0.6) + 320 | ggplot2::geom_errorbar(ggplot2::aes(Treatment, 321 | ymin = mean.expre - sd.expre, 322 | ymax = mean.expre + sd.expre 323 | ), 324 | width = 0.2 325 | ) + 326 | ggplot2::geom_jitter(ggplot2::aes(Treatment, expre), width = 0.1, alpha = 0.4) + 327 | ggplot2::geom_hline(ggplot2::aes(yintercept = max.temp * 1.1), color = NA) + 328 | ggplot2::facet_wrap(. ~ gene, scales = "free_y", ncol = fig.ncol) + 329 | ggplot2::geom_text(ggplot2::aes(Treatment, max.temp * 1.08, label = signif), 330 | check_overlap = TRUE, size = 4, color = "red" 331 | ) + 332 | ggthemes::theme_pander() + 333 | ggplot2::labs(y = "Relative expression") + 334 | ggplot2::theme( 335 | legend.position = "none", 336 | strip.text.x = ggplot2::element_text(face = "italic") 337 | ) -> p 338 | } 339 | res <- list(table = df.plot, figure = p) 340 | return(res) 341 | } 342 | -------------------------------------------------------------------------------- /R/CalExpRqPCR.R: -------------------------------------------------------------------------------- 1 | #' @name CalExpRqPCR 2 | #' @author Xiang LI 3 | #' 4 | #' @title Calculate expression using standard curve. 5 | #' @description Calculate expression using standard curve. 6 | #' 7 | #' @param cq.table The data frame of the position and cq value. 8 | #' @param design.table The data frame of the position and corresponding information. 9 | #' @param correction Correct expression value by reference gene. 10 | #' @param ref.gene The name of reference gene. 11 | #' @param ref.group The name of reference group. 12 | #' @param stat.method Statistical method. 13 | #' @param fig.type Output image type, `box` represents `boxplot`, `bar` represents `barplot`. 14 | #' @param fig.ncol Number of columes of figure. 15 | #' 16 | #' @export 17 | #' 18 | #' @return A list contain a table and a figure. 19 | #' 20 | #' @examples 21 | #' df1.path <- system.file("examples", "cal.expre.rqpcr.cq.txt", package = "qPCRtools") 22 | #' df2.path <- system.file("examples", "cal.expre.rqpcr.design.txt", package = "qPCRtools") 23 | #' 24 | #' cq.table <- read.table(df1.path, header = TRUE) 25 | #' design.table <- read.table(df2.path, header = TRUE) 26 | #' 27 | #' CalExpRqPCR(cq.table, 28 | #' design.table, 29 | #' ref.gene = NULL, 30 | #' ref.group = "CK", 31 | #' stat.method = "t.test", 32 | #' fig.type = "box", 33 | #' fig.ncol = NULL 34 | #' ) -> res 35 | #' 36 | #' res[["table"]] 37 | #' res[["figure"]] 38 | #' 39 | globalVariables(c( 40 | "cq.table", 41 | "curve.table", 42 | "design.table", 43 | "correction", 44 | "ref.gene", 45 | "stat.method", 46 | "ref.group", 47 | "fig.type", 48 | "fig.ncol", 49 | "out", 50 | "cq", 51 | "max.cq", 52 | "min.cq", 53 | "expre", 54 | "Intercept", 55 | "Slope", 56 | "Treatment", 57 | "element_text", 58 | "group2", 59 | "max.temp", 60 | "mean.expre", 61 | "mean.ref", 62 | "n", 63 | "sd", 64 | "sd.expre", 65 | "Treatment", 66 | "mean.ref", 67 | "group2", 68 | "temp", 69 | "n", 70 | "sd.expre", 71 | "n", 72 | "mean.expre", 73 | "element_text", 74 | "max.temp", 75 | "gene", 76 | "group", 77 | "biorep", 78 | "Target", 79 | "Reference", 80 | "ddct1", 81 | "mean.expression", 82 | "n.biorep", 83 | "sd.expression", 84 | "se.expression", 85 | "Reference", 86 | "Target", 87 | "biorep", 88 | "ddct1", 89 | "gene", 90 | "group", 91 | "mean.expression", 92 | "n.biorep", 93 | "sd.expression", 94 | "se.expression", 95 | 'sd.cq', 96 | 'eff', 97 | 'min.mean.cq', 98 | 'QCq', 99 | 'techrep', 100 | 'temp_2', 101 | 'SD_QCq', 102 | 'SD.factor', 103 | 'SD_1', 104 | 'min.expression', 105 | 'Expre4Stat', 106 | 'Expression', 107 | 'SD', 108 | 'SE', 109 | 'BioRep', 110 | 'Eff', 111 | 'Group', 112 | 'TechRep' 113 | )) 114 | CalExpRqPCR <- function(cq.table, 115 | design.table, 116 | ref.gene = NULL, 117 | ref.group = "CK", 118 | stat.method = "t.test", 119 | fig.type = "box", 120 | fig.ncol = NULL) { 121 | 122 | # merge data 123 | cq.table %>% 124 | dplyr::left_join(design.table, by = "Position") %>% 125 | dplyr::rename(position = Position, 126 | cq = Cq, 127 | group = Group, 128 | gene = Gene, 129 | biorep = BioRep, 130 | techrep = TechRep, 131 | eff = Eff) -> df 132 | 133 | # start cal 134 | df.expre <- df %>% 135 | dplyr::group_by(biorep, group, gene) %>% 136 | dplyr::mutate( 137 | mean.cq = mean(cq, na.rm = TRUE), 138 | sd.cq = sd(cq, na.rm = TRUE), 139 | sd.cq = ifelse(is.na(sd.cq), 0, sd.cq) 140 | ) %>% 141 | dplyr::ungroup() %>% 142 | dplyr::group_by(biorep, gene) %>% 143 | dplyr::mutate( 144 | min.mean.cq = min(mean.cq), 145 | QCq = eff^(min.mean.cq - mean.cq), 146 | SD_QCq = sd.cq * QCq * log(eff) 147 | ) %>% 148 | dplyr::ungroup() 149 | 150 | # find ref gene 151 | if (!is.null(ref.gene)) { 152 | ref.gene <- ref.gene 153 | } else { 154 | df.ref <- df.expre %>% 155 | dplyr::select(group, gene, cq, biorep, techrep) %>% 156 | # dplyr::group_by(Treatment, Gene, bio_rep, rep) %>% 157 | dplyr::mutate( 158 | Treatment = paste0(group, biorep, techrep) 159 | ) %>% 160 | tidyr::spread(key = gene, value = cq) 161 | 162 | df.temp <- df.ref[, 5:ncol(df.ref)] %>% as.data.frame() 163 | 164 | n <- length(unique(df.expre$gene)) 165 | 166 | M <- numeric(n) 167 | 168 | for (j in 1:n) { 169 | A <- log2(df.temp[, j] / df.temp[, -j]) 170 | if (n > 2) { 171 | M[j] <- mean(apply(A, 2, sd, na.rm = TRUE)) 172 | } else { 173 | M[j] <- sd(A, na.rm = TRUE) 174 | } 175 | } 176 | 177 | if (is.data.frame(df.temp)) { 178 | names(M) <- names(df.temp) 179 | } else { 180 | names(M) <- colnames(df.temp) 181 | } 182 | 183 | geneSymbol <- colnames(df.temp) 184 | n <- ncol(df.temp) 185 | 186 | num.ref <- 2 187 | 188 | V <- numeric(n - num.ref) 189 | names(V) <- paste(((n - 1):num.ref), "/", (n:(num.ref + 1)), sep = "") 190 | meanM <- numeric(n - num.ref + 1) 191 | names(meanM) <- as.character(n:num.ref) 192 | R <- character(n) 193 | names(R) <- as.character(c(rep(1, num.ref), (num.ref + 1):length(R))) 194 | 195 | geometric.mean <- function(x) { 196 | x <- x[!is.na(x)] 197 | if (any(x < 0)) { 198 | stop("'x' contains negative value(s)") 199 | } else { 200 | return(prod(x)^(1 / length(x))) 201 | } 202 | } 203 | 204 | gene.stable <- function(data, na.rm = TRUE) { 205 | if (!is.data.frame(data) & !is.matrix(data)) { 206 | stop("'data' has to of class matrix or data.frame") 207 | } 208 | n <- ncol(data) 209 | if (n == 1) stop("you need at least two genes for this computation") 210 | M <- numeric(n) 211 | for (j in 1:n) { 212 | A <- log2(data[, j] / data[, -j]) 213 | if (n > 2) { 214 | M[j] <- mean(apply(A, 2, sd, na.rm = na.rm)) 215 | } else { 216 | M[j] <- sd(A, na.rm = na.rm) 217 | } 218 | } 219 | if (is.data.frame(data)) { 220 | names(M) <- names(data) 221 | } else { 222 | names(M) <- colnames(data) 223 | } 224 | return(M) 225 | } 226 | 227 | 228 | for (i in n:num.ref) { 229 | M <- gene.stable(df.temp, na.rm = TRUE) 230 | ind <- which.max(M) 231 | meanM[n - i + 1] <- mean(M) 232 | if (i == num.ref) { 233 | R[1:num.ref] <- geneSymbol 234 | } else { 235 | R[i] <- geneSymbol[ind] 236 | } 237 | if (i > 2) { 238 | NF.old <- apply(df.temp, 1, geometric.mean) 239 | NF.new <- apply(df.temp[, -ind], 1, geometric.mean) 240 | V[n - i + 1] <- sd(log2(NF.new / NF.old), na.rm = TRUE) 241 | } 242 | df.temp <- df.temp[, -ind] 243 | geneSymbol <- geneSymbol[-ind] 244 | } 245 | 246 | ref.gene <- as.character(R[1:num.ref]) 247 | } 248 | 249 | #### cal factor 250 | df.factor <- df.expre %>% 251 | dplyr::filter(gene %in% ref.gene) %>% 252 | dplyr::mutate(temp_2 = paste0(group, biorep, gene)) 253 | df.factor <- df.factor[!duplicated(df.factor$temp_2), ] %>% as.data.frame() 254 | 255 | factor <- data.frame() 256 | 257 | for (i in unique(df.factor$biorep)) { 258 | df.temp <- df.factor %>% dplyr::filter(biorep == i) 259 | for (j in unique(df.temp$group)) { 260 | df.temp.2 <- df.temp %>% 261 | dplyr::filter(group == j) %>% 262 | dplyr::select(group, QCq) 263 | fac <- data.frame(group = j, biorep = i, factor = geometric.mean(df.temp.2$QCq)) 264 | factor <- rbind(factor, fac) 265 | } 266 | } 267 | 268 | factor <- factor %>% 269 | dplyr::mutate(temp_2 = paste0(group, biorep)) %>% 270 | dplyr::select(temp_2, factor) 271 | df.factor <- df.factor %>% 272 | dplyr::mutate(temp_2 = paste0(group, biorep)) %>% 273 | merge(factor, by = "temp_2") %>% 274 | dplyr::mutate(SD.factor = (SD_QCq / (length(ref.gene) * (QCq)))^2) %>% 275 | dplyr::group_by(biorep, group) %>% 276 | dplyr::mutate(SD.factor = sqrt(sum(SD.factor)) * factor) 277 | 278 | ################################### 279 | #### cal corred expresssion #### 280 | ################################### 281 | df.goi <- df.expre %>% 282 | dplyr::filter(!gene %in% ref.gene) %>% 283 | dplyr::mutate(temp_2 = paste0(group, biorep)) %>% 284 | merge(df.factor[, c("temp_2", "factor", "SD.factor")], by = "temp_2") %>% 285 | dplyr::mutate( 286 | expression = QCq / factor, 287 | SD_1 = expression * sqrt((SD_QCq / QCq)^2 + (SD.factor / factor)^2), 288 | SE_1 = SD_1 / sqrt(2) 289 | ) 290 | 291 | ################################### 292 | #### cal mean expression 293 | res.all <- df.goi %>% 294 | dplyr::ungroup() %>% 295 | # dplyr::mutate(Treatment = stringr::str_sub(Sample, 1, nchar(Sample) - 2)) %>% 296 | dplyr::group_by(gene, group) %>% 297 | dplyr::mutate( 298 | mean.expression = mean(unique(expression), na.rm = TRUE), 299 | sd.expression = sd(unique(expression), na.rm = TRUE), 300 | se.expression = sd.expression / sqrt(length(unique(biorep))) 301 | ) %>% 302 | dplyr::ungroup() %>% 303 | dplyr::group_by(gene) %>% 304 | dplyr::mutate( 305 | min.expression = min(mean.expression), 306 | mean.expression = mean.expression / min.expression, 307 | sd.expression = sd.expression / min.expression, 308 | se.expression = se.expression / min.expression 309 | ) %>% 310 | dplyr::select( 311 | group, gene, eff, expression, biorep, 312 | mean.expression, sd.expression, se.expression 313 | ) %>% 314 | dplyr::rename( 315 | Expre4Stat = expression, 316 | Expression = mean.expression, 317 | SD = sd.expression, 318 | SE = se.expression 319 | ) %>% 320 | dplyr::mutate(temp = paste0(group, gene, biorep)) %>% 321 | dplyr::filter(!duplicated(temp)) %>% 322 | dplyr::select(-temp) %>% 323 | dplyr::mutate(temp = paste0(gene, group)) 324 | 325 | # statistics 326 | if (stat.method == "t.test") { 327 | res.all %>% 328 | dplyr::group_by(gene) %>% 329 | rstatix::t_test(Expre4Stat ~ group, ref.group = ref.group) %>% 330 | dplyr::ungroup() %>% 331 | dplyr::select(gene, group2, p) %>% 332 | dplyr::mutate(signif = dplyr::case_when( 333 | p < 0.001 ~ "***", 334 | p > 0.001 & p < 0.01 ~ "**", 335 | p > 0.01 & p < 0.05 ~ "*", 336 | TRUE ~ "NS" 337 | )) %>% 338 | dplyr::add_row(group2 = ref.group, p = NA, signif = NA) %>% 339 | dplyr::rename(group = group2) %>% 340 | dplyr::mutate(temp = paste0(gene, group)) %>% 341 | dplyr::select(temp, signif) -> df.stat 342 | 343 | res.all <- res.all %>% 344 | dplyr::left_join(df.stat, by = "temp") 345 | } else if (stat.method == "wilcox.test") { 346 | res.all %>% 347 | dplyr::group_by(gene) %>% 348 | rstatix::wilcox_test(Expre4Stat ~ group, ref.group = ref.group) %>% 349 | dplyr::ungroup() %>% 350 | dplyr::select(gene, group2, p) %>% 351 | dplyr::mutate(signif = dplyr::case_when( 352 | p < 0.001 ~ "***", 353 | p > 0.001 & p < 0.01 ~ "**", 354 | p > 0.01 & p < 0.05 ~ "*", 355 | TRUE ~ "NS" 356 | )) %>% 357 | dplyr::add_row(group2 = ref.group, p = NA, signif = NA) %>% 358 | dplyr::rename(group = group2) %>% 359 | dplyr::mutate(temp = paste0(gene, group)) %>% 360 | dplyr::select(temp, signif) -> df.stat 361 | 362 | res.all <- res.all %>% 363 | dplyr::left_join(df.stat, by = "temp") 364 | } else { 365 | df.stat <- NULL 366 | for (i in unique(res.all$gene)) { 367 | df.sub <- res.all %>% 368 | dplyr::filter(gene == i) %>% 369 | dplyr::mutate(group = factor(group)) 370 | fit <- stats::aov(Expre4Stat ~ group, data = df.sub) 371 | tuk <- multcomp::glht(fit, linfct = multcomp::mcp(group = "Tukey")) 372 | multcomp::cld(tuk, level = 0.95, ddecreasing = TRUE)[["mcletters"]][["Letters"]] %>% 373 | as.data.frame() %>% 374 | dplyr::mutate(gene = i) %>% 375 | tibble::rownames_to_column(var = "group") %>% 376 | magrittr::set_colnames(c("group", "signif", "gene")) %>% 377 | dplyr::select(group, gene, signif) %>% 378 | dplyr::mutate(temp = paste0(group, gene)) %>% 379 | dplyr::select(temp, signif) %>% 380 | rbind(df.stat) -> df.stat 381 | } 382 | res.all %>% 383 | dplyr::mutate(temp = paste0(group, gene)) %>% 384 | dplyr::left_join(df.stat, by = "temp") -> res.all 385 | } 386 | 387 | # plot 388 | df.plot <- res.all %>% 389 | dplyr::rename( 390 | Treatment = group, 391 | gene = gene, 392 | expre = Expre4Stat, 393 | mean.expre = Expression, 394 | sd.expre = SD, 395 | se.expre = SE 396 | ) %>% 397 | dplyr::group_by(gene, Treatment) %>% 398 | dplyr::mutate(n = dplyr::n()) %>% 399 | dplyr::ungroup() 400 | 401 | if (fig.type == "box") { 402 | df.plot %>% 403 | ggplot2::ggplot(ggplot2::aes(Treatment, expre, fill = Treatment)) + 404 | ggplot2::geom_boxplot(width = 0.6) + 405 | ggplot2::facet_wrap(. ~ gene, scales = "free_y", ncol = fig.ncol) + 406 | ggplot2::geom_text(ggplot2::aes(Treatment, min(expre), label = signif), 407 | check_overlap = TRUE, size = 3, color = "black" 408 | ) + 409 | ggthemes::theme_pander() + 410 | ggplot2::labs(y = "Relative expression") + 411 | ggplot2::theme( 412 | legend.position = "none", 413 | strip.text.x = ggplot2::element_text(face = "italic") 414 | ) -> p 415 | } else if (fig.type == "bar") { 416 | df.plot %>% 417 | dplyr::group_by(gene) %>% 418 | dplyr::mutate(max.temp = max(mean.expre)) %>% 419 | dplyr::ungroup() %>% 420 | ggplot2::ggplot(ggplot2::aes(Treatment, mean.expre / n, fill = Treatment)) + 421 | ggplot2::geom_bar(stat = "identity", width = 0.6) + 422 | ggplot2::geom_errorbar(ggplot2::aes(Treatment, 423 | ymin = mean.expre - sd.expre, 424 | ymax = mean.expre + sd.expre 425 | ), 426 | width = 0.2 427 | ) + 428 | # ggplot2::geom_jitter(ggplot2::aes(Treatment, expre), width = 0.1, alpha = 0.4) + 429 | ggplot2::geom_hline(ggplot2::aes(yintercept = max.temp * 1.15), color = NA) + 430 | ggplot2::facet_wrap(. ~ gene, scales = "free_y", ncol = fig.ncol) + 431 | ggplot2::geom_text(ggplot2::aes(Treatment, (mean.expre + sd.expre) * 1.08, label = signif), 432 | check_overlap = TRUE, size = 4, color = "black" 433 | ) + 434 | ggthemes::theme_pander() + 435 | ggplot2::labs(y = "Relative expression") + 436 | ggplot2::theme( 437 | legend.position = "none", 438 | strip.text.x = ggplot2::element_text(face = "italic") 439 | ) -> p 440 | } 441 | res.all <- res.all %>% 442 | dplyr::select(-temp, -eff) %>% 443 | dplyr::select(1, 4, 2, 3, 5:7) 444 | res <- list(table = res.all, figure = p) 445 | return(res) 446 | } 447 | -------------------------------------------------------------------------------- /CRAN/qPCRtools/R/CalExpRqPCR.R: -------------------------------------------------------------------------------- 1 | #' @name CalExpRqPCR 2 | #' @author Xiang LI 3 | #' 4 | #' @title Calculate expression using standard curve. 5 | #' @description Calculate expression using standard curve. 6 | #' 7 | #' @param cq.table The data frame of the position and cq value. 8 | #' @param design.table The data frame of the position and corresponding information. 9 | #' @param correction Correct expression value by reference gene. 10 | #' @param ref.gene The name of reference gene. 11 | #' @param ref.group The name of reference group. 12 | #' @param stat.method Statistical method. 13 | #' @param fig.type Output image type, `box` represents `boxplot`, `bar` represents `barplot`. 14 | #' @param fig.ncol Number of columes of figure. 15 | #' 16 | #' @export 17 | #' 18 | #' @return A list contain a table and a figure. 19 | #' 20 | #' @examples 21 | #' df1.path <- system.file("examples", "cal.expre.rqpcr.cq.txt", package = "qPCRtools") 22 | #' df2.path <- system.file("examples", "cal.expre.rqpcr.design.txt", package = "qPCRtools") 23 | #' 24 | #' cq.table <- read.table(df1.path, header = TRUE) 25 | #' design.table <- read.table(df2.path, header = TRUE) 26 | #' 27 | #' CalExpRqPCR(cq.table, 28 | #' design.table, 29 | #' ref.gene = NULL, 30 | #' ref.group = "CK", 31 | #' stat.method = "t.test", 32 | #' fig.type = "box", 33 | #' fig.ncol = NULL 34 | #' ) -> res 35 | #' 36 | #' res[["table"]] 37 | #' res[["figure"]] 38 | #' 39 | globalVariables(c( 40 | "cq.table", 41 | "curve.table", 42 | "design.table", 43 | "correction", 44 | "ref.gene", 45 | "stat.method", 46 | "ref.group", 47 | "fig.type", 48 | "fig.ncol", 49 | "out", 50 | "cq", 51 | "max.cq", 52 | "min.cq", 53 | "expre", 54 | "Intercept", 55 | "Slope", 56 | "Treatment", 57 | "element_text", 58 | "group2", 59 | "max.temp", 60 | "mean.expre", 61 | "mean.ref", 62 | "n", 63 | "sd", 64 | "sd.expre", 65 | "Treatment", 66 | "mean.ref", 67 | "group2", 68 | "temp", 69 | "n", 70 | "sd.expre", 71 | "n", 72 | "mean.expre", 73 | "element_text", 74 | "max.temp", 75 | "gene", 76 | "group", 77 | "biorep", 78 | "Target", 79 | "Reference", 80 | "ddct1", 81 | "mean.expression", 82 | "n.biorep", 83 | "sd.expression", 84 | "se.expression", 85 | "Reference", 86 | "Target", 87 | "biorep", 88 | "ddct1", 89 | "gene", 90 | "group", 91 | "mean.expression", 92 | "n.biorep", 93 | "sd.expression", 94 | "se.expression", 95 | 'sd.cq', 96 | 'eff', 97 | 'min.mean.cq', 98 | 'QCq', 99 | 'techrep', 100 | 'temp_2', 101 | 'SD_QCq', 102 | 'SD.factor', 103 | 'SD_1', 104 | 'min.expression', 105 | 'Expre4Stat', 106 | 'Expression', 107 | 'SD', 108 | 'SE', 109 | 'BioRep', 110 | 'Eff', 111 | 'Group', 112 | 'TechRep' 113 | )) 114 | CalExpRqPCR <- function(cq.table, 115 | design.table, 116 | ref.gene = NULL, 117 | ref.group = "CK", 118 | stat.method = "t.test", 119 | fig.type = "box", 120 | fig.ncol = NULL) { 121 | 122 | # merge data 123 | cq.table %>% 124 | dplyr::left_join(design.table, by = "Position") %>% 125 | dplyr::rename(position = Position, 126 | cq = Cq, 127 | group = Group, 128 | gene = Gene, 129 | biorep = BioRep, 130 | techrep = TechRep, 131 | eff = Eff) -> df 132 | 133 | # start cal 134 | df.expre <- df %>% 135 | dplyr::group_by(biorep, group, gene) %>% 136 | dplyr::mutate( 137 | mean.cq = mean(cq, na.rm = TRUE), 138 | sd.cq = sd(cq, na.rm = TRUE), 139 | sd.cq = ifelse(is.na(sd.cq), 0, sd.cq) 140 | ) %>% 141 | dplyr::ungroup() %>% 142 | dplyr::group_by(biorep, gene) %>% 143 | dplyr::mutate( 144 | min.mean.cq = min(mean.cq), 145 | QCq = eff^(min.mean.cq - mean.cq), 146 | SD_QCq = sd.cq * QCq * log(eff) 147 | ) %>% 148 | dplyr::ungroup() 149 | 150 | # find ref gene 151 | if (!is.null(ref.gene)) { 152 | ref.gene <- ref.gene 153 | } else { 154 | df.ref <- df.expre %>% 155 | dplyr::select(group, gene, cq, biorep, techrep) %>% 156 | # dplyr::group_by(Treatment, Gene, bio_rep, rep) %>% 157 | dplyr::mutate( 158 | Treatment = paste0(group, biorep, techrep) 159 | ) %>% 160 | tidyr::spread(key = gene, value = cq) 161 | 162 | df.temp <- df.ref[, 5:ncol(df.ref)] %>% as.data.frame() 163 | 164 | n <- length(unique(df.expre$gene)) 165 | 166 | M <- numeric(n) 167 | 168 | for (j in 1:n) { 169 | A <- log2(df.temp[, j] / df.temp[, -j]) 170 | if (n > 2) { 171 | M[j] <- mean(apply(A, 2, sd, na.rm = TRUE)) 172 | } else { 173 | M[j] <- sd(A, na.rm = TRUE) 174 | } 175 | } 176 | 177 | if (is.data.frame(df.temp)) { 178 | names(M) <- names(df.temp) 179 | } else { 180 | names(M) <- colnames(df.temp) 181 | } 182 | 183 | geneSymbol <- colnames(df.temp) 184 | n <- ncol(df.temp) 185 | 186 | num.ref <- 2 187 | 188 | V <- numeric(n - num.ref) 189 | names(V) <- paste(((n - 1):num.ref), "/", (n:(num.ref + 1)), sep = "") 190 | meanM <- numeric(n - num.ref + 1) 191 | names(meanM) <- as.character(n:num.ref) 192 | R <- character(n) 193 | names(R) <- as.character(c(rep(1, num.ref), (num.ref + 1):length(R))) 194 | 195 | geometric.mean <- function(x) { 196 | x <- x[!is.na(x)] 197 | if (any(x < 0)) { 198 | stop("'x' contains negative value(s)") 199 | } else { 200 | return(prod(x)^(1 / length(x))) 201 | } 202 | } 203 | 204 | gene.stable <- function(data, na.rm = TRUE) { 205 | if (!is.data.frame(data) & !is.matrix(data)) { 206 | stop("'data' has to of class matrix or data.frame") 207 | } 208 | n <- ncol(data) 209 | if (n == 1) stop("you need at least two genes for this computation") 210 | M <- numeric(n) 211 | for (j in 1:n) { 212 | A <- log2(data[, j] / data[, -j]) 213 | if (n > 2) { 214 | M[j] <- mean(apply(A, 2, sd, na.rm = na.rm)) 215 | } else { 216 | M[j] <- sd(A, na.rm = na.rm) 217 | } 218 | } 219 | if (is.data.frame(data)) { 220 | names(M) <- names(data) 221 | } else { 222 | names(M) <- colnames(data) 223 | } 224 | return(M) 225 | } 226 | 227 | 228 | for (i in n:num.ref) { 229 | M <- gene.stable(df.temp, na.rm = TRUE) 230 | ind <- which.max(M) 231 | meanM[n - i + 1] <- mean(M) 232 | if (i == num.ref) { 233 | R[1:num.ref] <- geneSymbol 234 | } else { 235 | R[i] <- geneSymbol[ind] 236 | } 237 | if (i > 2) { 238 | NF.old <- apply(df.temp, 1, geometric.mean) 239 | NF.new <- apply(df.temp[, -ind], 1, geometric.mean) 240 | V[n - i + 1] <- sd(log2(NF.new / NF.old), na.rm = TRUE) 241 | } 242 | df.temp <- df.temp[, -ind] 243 | geneSymbol <- geneSymbol[-ind] 244 | } 245 | 246 | ref.gene <- as.character(R[1:num.ref]) 247 | } 248 | 249 | #### cal factor 250 | df.factor <- df.expre %>% 251 | dplyr::filter(gene %in% ref.gene) %>% 252 | dplyr::mutate(temp_2 = paste0(group, biorep, gene)) 253 | df.factor <- df.factor[!duplicated(df.factor$temp_2), ] %>% as.data.frame() 254 | 255 | factor <- data.frame() 256 | 257 | for (i in unique(df.factor$biorep)) { 258 | df.temp <- df.factor %>% dplyr::filter(biorep == i) 259 | for (j in unique(df.temp$group)) { 260 | df.temp.2 <- df.temp %>% 261 | dplyr::filter(group == j) %>% 262 | dplyr::select(group, QCq) 263 | fac <- data.frame(group = j, biorep = i, factor = geometric.mean(df.temp.2$QCq)) 264 | factor <- rbind(factor, fac) 265 | } 266 | } 267 | 268 | factor <- factor %>% 269 | dplyr::mutate(temp_2 = paste0(group, biorep)) %>% 270 | dplyr::select(temp_2, factor) 271 | df.factor <- df.factor %>% 272 | dplyr::mutate(temp_2 = paste0(group, biorep)) %>% 273 | merge(factor, by = "temp_2") %>% 274 | dplyr::mutate(SD.factor = (SD_QCq / (length(ref.gene) * (QCq)))^2) %>% 275 | dplyr::group_by(biorep, group) %>% 276 | dplyr::mutate(SD.factor = sqrt(sum(SD.factor)) * factor) 277 | 278 | ################################### 279 | #### cal corred expresssion #### 280 | ################################### 281 | df.goi <- df.expre %>% 282 | dplyr::filter(!gene %in% ref.gene) %>% 283 | dplyr::mutate(temp_2 = paste0(group, biorep)) %>% 284 | merge(df.factor[, c("temp_2", "factor", "SD.factor")], by = "temp_2") %>% 285 | dplyr::mutate( 286 | expression = QCq / factor, 287 | SD_1 = expression * sqrt((SD_QCq / QCq)^2 + (SD.factor / factor)^2), 288 | SE_1 = SD_1 / sqrt(2) 289 | ) 290 | 291 | ################################### 292 | #### cal mean expression 293 | res.all <- df.goi %>% 294 | dplyr::ungroup() %>% 295 | # dplyr::mutate(Treatment = stringr::str_sub(Sample, 1, nchar(Sample) - 2)) %>% 296 | dplyr::group_by(gene, group) %>% 297 | dplyr::mutate( 298 | mean.expression = mean(unique(expression), na.rm = TRUE), 299 | sd.expression = sd(unique(expression), na.rm = TRUE), 300 | se.expression = sd.expression / sqrt(length(unique(biorep))) 301 | ) %>% 302 | dplyr::ungroup() %>% 303 | dplyr::group_by(gene) %>% 304 | dplyr::mutate( 305 | min.expression = min(mean.expression), 306 | mean.expression = mean.expression / min.expression, 307 | sd.expression = sd.expression / min.expression, 308 | se.expression = se.expression / min.expression 309 | ) %>% 310 | dplyr::select( 311 | group, gene, eff, expression, biorep, 312 | mean.expression, sd.expression, se.expression 313 | ) %>% 314 | dplyr::rename( 315 | Expre4Stat = expression, 316 | Expression = mean.expression, 317 | SD = sd.expression, 318 | SE = se.expression 319 | ) %>% 320 | dplyr::mutate(temp = paste0(group, gene, biorep)) %>% 321 | dplyr::filter(!duplicated(temp)) %>% 322 | dplyr::select(-temp) %>% 323 | dplyr::mutate(temp = paste0(gene, group)) 324 | 325 | # statistics 326 | if (stat.method == "t.test") { 327 | res.all %>% 328 | dplyr::group_by(gene) %>% 329 | rstatix::t_test(Expre4Stat ~ group, ref.group = ref.group) %>% 330 | dplyr::ungroup() %>% 331 | dplyr::select(gene, group2, p) %>% 332 | dplyr::mutate(signif = dplyr::case_when( 333 | p < 0.001 ~ "***", 334 | p > 0.001 & p < 0.01 ~ "**", 335 | p > 0.01 & p < 0.05 ~ "*", 336 | TRUE ~ "NS" 337 | )) %>% 338 | dplyr::add_row(group2 = ref.group, p = NA, signif = NA) %>% 339 | dplyr::rename(group = group2) %>% 340 | dplyr::mutate(temp = paste0(gene, group)) %>% 341 | dplyr::select(temp, signif) -> df.stat 342 | 343 | res.all <- res.all %>% 344 | dplyr::left_join(df.stat, by = "temp") 345 | } else if (stat.method == "wilcox.test") { 346 | res.all %>% 347 | dplyr::group_by(gene) %>% 348 | rstatix::wilcox_test(Expre4Stat ~ group, ref.group = ref.group) %>% 349 | dplyr::ungroup() %>% 350 | dplyr::select(gene, group2, p) %>% 351 | dplyr::mutate(signif = dplyr::case_when( 352 | p < 0.001 ~ "***", 353 | p > 0.001 & p < 0.01 ~ "**", 354 | p > 0.01 & p < 0.05 ~ "*", 355 | TRUE ~ "NS" 356 | )) %>% 357 | dplyr::add_row(group2 = ref.group, p = NA, signif = NA) %>% 358 | dplyr::rename(group = group2) %>% 359 | dplyr::mutate(temp = paste0(gene, group)) %>% 360 | dplyr::select(temp, signif) -> df.stat 361 | 362 | res.all <- res.all %>% 363 | dplyr::left_join(df.stat, by = "temp") 364 | } else { 365 | df.stat <- NULL 366 | for (i in unique(res.all$gene)) { 367 | df.sub <- res.all %>% 368 | dplyr::filter(gene == i) %>% 369 | dplyr::mutate(group = factor(group)) 370 | fit <- stats::aov(Expre4Stat ~ group, data = df.sub) 371 | tuk <- multcomp::glht(fit, linfct = multcomp::mcp(group = "Tukey")) 372 | multcomp::cld(tuk, level = 0.95, ddecreasing = TRUE)[["mcletters"]][["Letters"]] %>% 373 | as.data.frame() %>% 374 | dplyr::mutate(gene = i) %>% 375 | tibble::rownames_to_column(var = "group") %>% 376 | magrittr::set_colnames(c("group", "signif", "gene")) %>% 377 | dplyr::select(group, gene, signif) %>% 378 | dplyr::mutate(temp = paste0(group, gene)) %>% 379 | dplyr::select(temp, signif) %>% 380 | rbind(df.stat) -> df.stat 381 | } 382 | res.all %>% 383 | dplyr::mutate(temp = paste0(group, gene)) %>% 384 | dplyr::left_join(df.stat, by = "temp") -> res.all 385 | } 386 | 387 | # plot 388 | df.plot <- res.all %>% 389 | dplyr::rename( 390 | Treatment = group, 391 | gene = gene, 392 | expre = Expre4Stat, 393 | mean.expre = Expression, 394 | sd.expre = SD, 395 | se.expre = SE 396 | ) %>% 397 | dplyr::group_by(gene, Treatment) %>% 398 | dplyr::mutate(n = dplyr::n()) %>% 399 | dplyr::ungroup() 400 | 401 | if (fig.type == "box") { 402 | df.plot %>% 403 | ggplot2::ggplot(ggplot2::aes(Treatment, expre, fill = Treatment)) + 404 | ggplot2::geom_boxplot(width = 0.6) + 405 | ggplot2::facet_wrap(. ~ gene, scales = "free_y", ncol = fig.ncol) + 406 | ggplot2::geom_text(ggplot2::aes(Treatment, min(expre), label = signif), 407 | check_overlap = TRUE, size = 3, color = "black" 408 | ) + 409 | ggthemes::theme_pander() + 410 | ggplot2::labs(y = "Relative expression") + 411 | ggplot2::theme( 412 | legend.position = "none", 413 | strip.text.x = ggplot2::element_text(face = "italic") 414 | ) -> p 415 | } else if (fig.type == "bar") { 416 | df.plot %>% 417 | dplyr::group_by(gene) %>% 418 | dplyr::mutate(max.temp = max(mean.expre)) %>% 419 | dplyr::ungroup() %>% 420 | ggplot2::ggplot(ggplot2::aes(Treatment, mean.expre / n, fill = Treatment)) + 421 | ggplot2::geom_bar(stat = "identity", width = 0.6) + 422 | ggplot2::geom_errorbar(ggplot2::aes(Treatment, 423 | ymin = mean.expre - sd.expre, 424 | ymax = mean.expre + sd.expre 425 | ), 426 | width = 0.2 427 | ) + 428 | # ggplot2::geom_jitter(ggplot2::aes(Treatment, expre), width = 0.1, alpha = 0.4) + 429 | ggplot2::geom_hline(ggplot2::aes(yintercept = max.temp * 1.15), color = NA) + 430 | ggplot2::facet_wrap(. ~ gene, scales = "free_y", ncol = fig.ncol) + 431 | ggplot2::geom_text(ggplot2::aes(Treatment, (mean.expre + sd.expre) * 1.08, label = signif), 432 | check_overlap = TRUE, size = 4, color = "black" 433 | ) + 434 | ggthemes::theme_pander() + 435 | ggplot2::labs(y = "Relative expression") + 436 | ggplot2::theme( 437 | legend.position = "none", 438 | strip.text.x = ggplot2::element_text(face = "italic") 439 | ) -> p 440 | } 441 | res.all <- res.all %>% 442 | dplyr::select(-temp, -eff) %>% 443 | dplyr::select(1, 4, 2, 3, 5:7) 444 | res <- list(table = res.all, figure = p) 445 | return(res) 446 | } 447 | -------------------------------------------------------------------------------- /vignettes/chinese-gb7714-2005-numeric.csl: -------------------------------------------------------------------------------- 1 | 2 | 452 | --------------------------------------------------------------------------------