MahShaaban / pcr

Quality assessing, analyzing and testing the statistical significance of real-time quantitative PCR data
https://CRAN.R-project.org/package=pcr
GNU General Public License v3.0
27 stars 8 forks source link

Data formatting #10

Closed sgmccalla closed 5 years ago

sgmccalla commented 5 years ago

Could you please provide some tips on data formatting/loading data, other than using system.file to load the data? Thank you

MahShaaban commented 5 years ago

Hi @sgmccalla

Thanks for reaching out.

All pcr functions accept a data.frame/tibble with Ct values of genes in columns and samples in rows. You are free to construct the data.frame the way you prefer or load the data from files as approptiate.

Here, are two simple examples.

  1. Construct data.frame in R
# manually construct data.frame of ct values
ct1 <- data.frame(
    c_myc = c(30.72, 30.34, 30.58, 30.34, 30.50, 30.43, 27.06, 27.03, 27.03, 27.10, 26.99, 26.94),
    GAPDH = c(23.70, 23.56, 23.47, 23.65, 23.69, 23.68, 22.76, 22.61, 22.62, 22.60, 22.61, 22.76)
)

# make a group variable
group <- rep(c('brain', 'kidney'), each = 6)
  1. Load data from txt file
# load `ct1.txt` file from the current directory
ct1 <- read.csv('./ct1.txt')

# make a group variable
group <- rep(c('brain', 'kidney'), each = 6)

I attaced a comma separated file called ct1.txt to this comment and you can use it to try the examples. This is the samy file that comes with the package and is loaded in the vignette using system.file.

To make sure the data.frame is in the right format, the number of columns ncol should be exactly the number of genes/primers and the number of rows nrow should be exaclty the number of samples in the experiment. Finally the length of the group variable should also equal the number of rows. In the previous examples this should look something like this

ncol(ct1) == 2
#> TRUE

nrow(ct1) == 12
#> TRUE

nrow(ct1) == length(group)
#> TRUE

Please, let me know if you have other questions