Instalación de paqueteria

if (!requireNamespace("pacman", quietly = FALSE)) {
  install.packages("pacman")
}
## Loading required namespace: pacman
library("pacman")
## Warning: package 'pacman' was built under R version 4.4.3
p_load("vroom", 
       "dplyr",
       "ggplot2")

Llamar base de datos

Datos_PCR <- vroom::vroom("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.
head (Datos_PCR)
## # A tibble: 6 × 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

#Filtrar datos

Filtrado <- Datos_PCR %>% #Ctrl/Cmnd+Shift+M
  filter(Practica == "Relativa") %>%
  filter(Grupo == "G2") %>%
  select("Well", "Cq")

Filtrado
## # A tibble: 5 × 2
##   Well        Cq
##   <chr>    <dbl>
## 1 Profesor  30.7
## 2 B01       20.3
## 3 C01       18.7
## 4 D01       20.5
## 5 E01       34.2

#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 2^-DCt

Dos_DCt <- Filtrado %>% 
  mutate(DCt = (Cq-Referencia$Cq),
         DosDCt = 2^-DCt)
Dos_DCt
## # A tibble: 5 × 4
##   Well        Cq    DCt    DosDCt
##   <chr>    <dbl>  <dbl>     <dbl>
## 1 Profesor  30.7 12.3   0.000198 
## 2 B01       20.3  1.89  0.270    
## 3 C01       18.7  0.345 0.787    
## 4 D01       20.5  2.10  0.233    
## 5 E01       34.2 15.8   0.0000170

#Obtener el valor de 2^-DDCt

Dos_DDCt <- Dos_DCt %>%
  mutate(DosDDCt = DosDCt/last(DosDCt), 
         L2 = log2 (DosDDCt)) %>%
  slice(1,5)

Dos_DDCt
## # A tibble: 2 × 6
##   Well        Cq   DCt    DosDCt DosDDCt    L2
##   <chr>    <dbl> <dbl>     <dbl>   <dbl> <dbl>
## 1 Profesor  30.7  12.3 0.000198     11.6  3.54
## 2 E01       34.2  15.8 0.0000170     1    0

#Graficar datos

Grafica_comparativa <- ggplot(Dos_DDCt,
                              aes(x = Well,
                                  y = DosDDCt,
                                  fill = Well))+
  geom_col()+
  theme_classic()+
  labs(title = "Analisis Relativo RT-qPCR",
       subtitle = "Tejido: Bazo",
       caption = "Diseño Johan Medina",
       x = "Muestra",
       y = "Fold Change (2^-DDCt")

Grafica_comparativa

#Grafica Logartimo

Dos_DDCt2 <- Dos_DCt %>%
  mutate(DosDDCt = DosDCt/last(DosDCt), 
         L2 = log2 (DosDDCt))


Grafica_comparativa2 <- ggplot(Dos_DDCt2,
                              aes(x = Well,
                                  y = L2,
                                  fill = Well))+
  geom_col()+
    theme_classic()+
  labs(title = "Analisis Relativo RT-qPCR",
       subtitle = "Tejido: Bazo",
       caption = "Diseño Johan Medina",
       x = "Muestra",
       y = "Log2(Fold Change)")+
  geom_hline( yintercept = 0,
              linetype = "solid",
              color = "black",
              linewidth = 0.2)

Grafica_comparativa2