Code Monkey home page Code Monkey logo

Comments (3)

MahShaaban avatar MahShaaban commented on June 16, 2024

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

from pcr.

CamillaMaciel avatar CamillaMaciel commented on June 16, 2024

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))

from pcr.

MahShaaban avatar MahShaaban commented on June 16, 2024

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.

from pcr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.