if(!requireNamespace("pacman", quietly = F))
install.packages("pacman")
## Loading required namespace: pacman

Loading required namespace: pacman

library("pacman")
p_load("vroom",
"dplyr",
"ggplot2",
"tidyr" )
Datos_PCR <- vroom (file ="https://raw.githubusercontent.com/ManuelLaraMVZ/resultados_PCR_practica/refs/heads/main/Cts1.csv")
## Rows: 32 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): Well, Grupo, Practica, Fluor
## dbl (1): Cq
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
            Datos_PCR
## # A tibble: 32 × 5
##    Well     Grupo Practica Fluor    Cq
##    <chr>    <chr> <chr>    <chr> <dbl>
##  1 A01      G1    Relativa SYBR   30.8
##  2 B01      G1    Relativa SYBR   41  
##  3 C01      G1    Relativa SYBR   26.1
##  4 D01      G1    Relativa SYBR   41  
##  5 E01      G1    Relativa SYBR   41  
##  6 F01      G1    Relativa SYBR   22.3
##  7 Profesor G1    Relativa SYBR   30.7
##  8 Profesor G2    Relativa SYBR   30.7
##  9 B01      G2    Relativa SYBR   20.3
## 10 C01      G2    Relativa SYBR   18.7
## # ℹ 22 more rows

Filtrar datos

Filtrado <- Datos_PCR %>%
filter(Practica=="Relativa") %>%
filter(Grupo=="G1") %>%
select("Well","Cq")
Filtrado
## # A tibble: 7 × 2
##   Well        Cq
##   <chr>    <dbl>
## 1 A01       30.8
## 2 B01       41  
## 3 C01       26.1
## 4 D01       41  
## 5 E01       41  
## 6 F01       22.3
## 7 Profesor  30.7

Filtrar Datos

Filtrado <- Datos_PCR %>%
filter(Practica=="Relativa") %>%
filter(Grupo=="G1") %>%
select("Well","Cq")
Filtrado
## # A tibble: 7 × 2
##   Well        Cq
##   <chr>    <dbl>
## 1 A01       30.8
## 2 B01       41  
## 3 C01       26.1
## 4 D01       41  
## 5 E01       41  
## 6 F01       22.3
## 7 Profesor  30.7

Valor de gen de referencia

Referencia <- Datos_PCR %>%
filter(Grupo=="Referencia") %>%
select("Well","Cq")
Referencia
## # A tibble: 1 × 2
##   Well          Cq
##   <chr>      <dbl>
## 1 Referencia  18.4

Valor de 2ˆ-DCt

Dos_DCt <- Filtrado %>%
  mutate(DCt = Cq - Referencia$Cq,
         DosDCt = 2^-DCt)
Dos_DCt
## # A tibble: 7 × 4
##   Well        Cq   DCt      DosDCt
##   <chr>    <dbl> <dbl>       <dbl>
## 1 A01       30.8 12.4  0.000181   
## 2 B01       41   22.6  0.000000157
## 3 C01       26.1  7.72 0.00473    
## 4 D01       41   22.6  0.000000157
## 5 E01       41   22.6  0.000000157
## 6 F01       22.3  3.94 0.0652     
## 7 Profesor  30.7 12.3  0.000198

Obtener el valor de 2ˆ-DDCt

Dos_DDCt <- Dos_DCt %>%
mutate(Dos_DDCt=DosDCt/last(DosDCt),
L2 = log2(Dos_DDCt))
  
Dos_DDCt
## # A tibble: 7 × 6
##   Well        Cq   DCt      DosDCt   Dos_DDCt      L2
##   <chr>    <dbl> <dbl>       <dbl>      <dbl>   <dbl>
## 1 A01       30.8 12.4  0.000181      0.915     -0.128
## 2 B01       41   22.6  0.000000157   0.000794 -10.3  
## 3 C01       26.1  7.72 0.00473      23.9        4.58 
## 4 D01       41   22.6  0.000000157   0.000794 -10.3  
## 5 E01       41   22.6  0.000000157   0.000794 -10.3  
## 6 F01       22.3  3.94 0.0652      329.         8.36 
## 7 Profesor  30.7 12.3  0.000198      1          0

Graficar datos

Grafica_comparativa <- ggplot(Dos_DDCt,
                            aes(x=Well,
                                y= Dos_DDCt,
                            fill= Well)) +
  geom_col()+
theme_classic()+
  labs(tittle= "Anaslisis relativo RT-qPCR",
       subtitle = "Tejido",
       caption = "Elaborado por: equipo uno",
       x="Muestra",
       y="Fold change (2ˆ-DDCt)")
geom_hline(yintercept = 0,
           linetype= "solid",
           color= "black",
           linewidth= 1)
## mapping: yintercept = ~yintercept 
## geom_hline: na.rm = FALSE
## stat_identity: na.rm = FALSE
## position_identity
Grafica_comparativa

Grafica Logaritmo

Grafica_comparativa2 <- ggplot(Dos_DDCt,
                            aes(x=Well,
                                y= L2,
                            fill= Well)) +
  geom_col() +
  theme_classic()+
  labs(tittle= "Anaslisis relativo RT-qPCR",
       subtitle = "Tejido",
       caption = "Elaborado por: equipo uno",
       x="Muestra",
       y="Log 2 del Fold change")
geom_hline(yintercept = 0,
           linetype= "solid",
           color= "black",
           linewidth= 1)
## mapping: yintercept = ~yintercept 
## geom_hline: na.rm = FALSE
## stat_identity: na.rm = FALSE
## position_identity
Grafica_comparativa2