Closed CamillaMaciel closed 3 years ago
Hi @CamillaMaciel
I don't think you need to do much beyond the looping, since the calculation are applied for each assay (gene) separately.
How about splitting the original data df
into smaller subsets based on Assay.Name
and use map
to call pcr_assess
# load libraries
library(pcr)
library(tidyverse)
# apply pcr_assess on each assay separately
df %>%
group_split(Assay.Name) %>%
setNames(unique(df$Assay.Name)) %>%
map(~{
pcr_assess(select(.x, CT), # use select to return a data.frame
amount = pull(.x, Sample.Name)) # use pull to return a vector
})
#> $Assay01
#> gene intercept slope r_squared
#> 1 CT 9.864613 -3.520934 0.9983931
#>
#> $Assay02
#> gene intercept slope r_squared
#> 1 CT 10.94083 -3.483191 0.9996576
#>
#> $Assay03
#> gene intercept slope r_squared
#> 1 CT 10.35883 -3.40583 0.9996625
Created on 2021-07-22 by the reprex package (v2.0.0)
Please let me know if you have other questions
Hi Mahmoud. Thank you so much for your reply. It works super fine :)
I also added these lines for calculating the efficiency:
# apply pcr_assess on each assay separately
res<- df %>%
group_split(Assay.Name) %>%
setNames(unique(std_bQC$Assay.Name)) %>%
map(~{
pcr_assess(select(.x, CT), # use select to return a data.frame
amount = pull(.x, Sample.Name)) # use pull to return a vector
})
# Calculate efficiency
df2<- lapply(df, function(x)
cbind(x, efficiency = (10^(-1/x$slope)-1)*100))
I am glad it worked.
There is a way to calculate the efficiency in the pcr
package. You only need to add method == 'efficiency'
along with the name of the reference_gene
in pcr_assess
.
Hi Mahmoud, Thank you for this very useful package. Now I am trying to use for a bigger dataset where I have several Assays (genes) but the standard curves have different number of replicates, because I had to apply filters and some of them got removed. This way the 'amount' does not represent all Assays (genes) and therefore the R2 cannot be calculated. I tried to create an amount list for each one of the genes with the precise amount of replicates for each. I am not sure how to run a loop within the function 'pcr_assess' and get the results for all the Assays.