if(!require(pacman))
  install.packages("pacman")
## Loading required package: pacman
install.packages("dyplr")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
## Warning: package 'dyplr' is not available for this version of R
## 
## A version of this package for your version of R might be available elsewhere,
## see the ideas at
## https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
library("pacman")
library("dplyr")
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
p_load("vroom",
       "dyplyr",
       "ggplot2",
       "tidyr")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
## Warning: package 'dyplyr' is not available for this version of R
## 
## A version of this package for your version of R might be available elsewhere,
## see the ideas at
## https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
## Warning: 'BiocManager' not available.  Could not check Bioconductor.
## 
## Please use `install.packages('BiocManager')` and then retry.
## Warning in p_install(package, character.only = TRUE, ...):
## Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
## logical.return = TRUE, : there is no package called 'dyplyr'
## Warning in p_load("vroom", "dyplyr", "ggplot2", "tidyr"): Failed to install/load:
## dyplyr
Curvas_amplif<- vroom(file="https://raw.githubusercontent.com/ManuelLaraMVZ/resultados_PCR_practica/refs/heads/main/Amplif_grupo1_24022025.csv")
## `curl` package not installed, falling back to using `url()`
## Rows: 51 Columns: 9
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (9): Cycle, A1, B1, C1, D1, E1, F1, G1, Manuel
## 
## ℹ 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.
Curvas_amplif
## # A tibble: 51 × 9
##    Cycle     A1     B1     C1     D1      E1     F1      G1 Manuel
##    <dbl>  <dbl>  <dbl>  <dbl>  <dbl>   <dbl>  <dbl>   <dbl>  <dbl>
##  1     1 -732.  -450.  -50.4  -30.1  -109.   -10.7  -5.87   -37.4 
##  2     2 -402.  -237.  -20.8   15.9   -80.6  -10.4  -8.17     1.12
##  3     3 -294.  -171.  -14.1   11.9   -71.2   -7.35 -5.06     7.85
##  4     4 -322.  -143.    8.14  13.6   -60.4   -6.83 -3.26    15.0 
##  5     5 -300.  -100.   12.1    5.93  -54.7   -3.67 -3.51     8.92
##  6     6 -277.   -84.8  17.0   14.6   -41.4    1.04  0.0908   6.62
##  7     7 -232.   -78.9  14.0   10.8   -31.2   -2.24 -2.85    -4.64
##  8     8 -197.   -61.4  14.8   13.6   -23.1    3.22  4.79    -2.66
##  9     9 -143.   -39.9  11.0   10.4   -13.4    4.09  2.17    -4.38
## 10    10  -95.6  -12.9   3.21   8.78   -2.80   2.80 -0.0460  28.3 
## # ℹ 41 more rows
Curvas_amplif2<- Curvas_amplif %>%
  mutate(Ciclos = Cycle, 
         PPBA = A1,
         ZARX = B1, 
         FFSS= C1,
         LANS = D1, 
         NEGATIVO = E1, 
         D2MI = F1,
         Control = Manuel) %>%
  select(-Cycle:-Manuel)%>%
  filter(Ciclos>=6)
Curvas_amplif2
## # A tibble: 46 × 8
##    Ciclos    PPBA   ZARX  FFSS   LANS NEGATIVO   D2MI Control
##     <dbl>   <dbl>  <dbl> <dbl>  <dbl>    <dbl>  <dbl>   <dbl>
##  1      6 -277.   -84.8  17.0  14.6    -41.4    1.04     6.62
##  2      7 -232.   -78.9  14.0  10.8    -31.2   -2.24    -4.64
##  3      8 -197.   -61.4  14.8  13.6    -23.1    3.22    -2.66
##  4      9 -143.   -39.9  11.0  10.4    -13.4    4.09    -4.38
##  5     10  -95.6  -12.9   3.21  8.78    -2.80   2.80    28.3 
##  6     11  -78.1  -13.1   2.47  1.01     0.325  0.486   97.9 
##  7     12  -35.1   -1.24 -3.91  2.81     9.72   1.88   242.  
##  8     13  -44.5    1.21  7.42 -0.884   13.2   -5.39   523.  
##  9     14    4.89  11.1  28.0   7.84    21.5   -0.898 1007.  
## 10     15   16.6   11.7  57.1  16.4     26.2    0.640 1841.  
## # ℹ 36 more rows
Curvas_amplif3 <- Curvas_amplif2%>%
  pivot_longer(cols= -Ciclos,
               names_to = "Muestras",
               values_to = "Fluorescencias" )
Curvas_amplif3
## # A tibble: 322 × 3
##    Ciclos Muestras Fluorescencias
##     <dbl> <chr>             <dbl>
##  1      6 PPBA            -277.  
##  2      6 ZARX             -84.8 
##  3      6 FFSS              17.0 
##  4      6 LANS              14.6 
##  5      6 NEGATIVO         -41.4 
##  6      6 D2MI               1.04
##  7      6 Control            6.62
##  8      7 PPBA            -232.  
##  9      7 ZARX             -78.9 
## 10      7 FFSS              14.0 
## # ℹ 312 more rows
Grafica_amplif<- ggplot(data = Curvas_amplif3,
                        mapping = aes(x=Ciclos,
                                      y=Fluorescencias,
                                      colour = Muestras))+
  geom_line (linewidth=1.5)
Grafica_amplif

Umbral_ciclos<- 300

Grafica_amplif2<- Grafica_amplif+
  geom_hline(yintercept = Umbral_ciclos, linetype = "dashed", color="#1e2bf9")+
  theme_classic()+
  labs(title = "Curvas de aamplificación RT-qPCR",
       subtitle = "Todas las muestras",
       caption = "Diseñaron: FFSS",
       x="Ciclos", 
       y="Fluorescencia (u.a.)")+
  theme(axis.line = element_line(size = 1.2, color = "black"),
        axis.title = element_text(face = "bold"),
        axis.text = element_text(face = "bold"),
        legend.title = element_text(face = "bold"),
        legend.text = element_text(face = "bold"))+
  scale_x_continuous(breaks = seq(min(Curvas_amplif3$Ciclos),
                                  max(Curvas_amplif3$Ciclos),
                                  by=10))+
  scale_y_continuous(breaks = seq(min(Curvas_amplif3$Fluorescencias),
                                  max(Curvas_amplif3$Fluorescencias),
                                  by=1500),
                     labels = scales::number_format(accuracy = 1500))
## Warning: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0.
## ℹ Please use the `linewidth` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
Grafica_amplif2

Grafica_amplif_equipo <- ggplot(Curvas_amplif2, aes(x = Ciclos)) +
  geom_line(aes(y = FFSS, color = "FFSS"), linewidth = 1.2) +
  geom_line(aes(y = NEGATIVO, color = "Negativo"), linewidth = 1.2) +
  geom_line(aes(y = Control, color = "Control"), linewidth = 1.2) +
  geom_hline(yintercept = Umbral_ciclos, linetype = "dashed", color = "#1e2bf9") +
  theme_classic() +
  labs(title = "Curvas de Amplificación RT-qPCR",
       subtitle = "Todas las muestras",
       caption = "Diseñaron: FFSS",
       x = "Ciclos", 
       y = "Fluorescencia (u.a.)",
       color = "Muestras") +  # Agregar título a la leyenda
  theme(axis.line = element_line(size = 1.2, color = "black"),
        axis.title = element_text(face = "bold"),
        axis.text = element_text(face = "bold"),
        legend.title = element_text(face = "bold"),
        legend.text = element_text(face = "bold")) +
  scale_x_continuous(breaks = seq(min(Curvas_amplif3$Ciclos),
                                  max(Curvas_amplif3$Ciclos),
                                  by = 5)) +
  scale_y_continuous(breaks = seq(min(Curvas_amplif3$Fluorescencias),
                                  max(Curvas_amplif3$Fluorescencias),
                                  by = 1000),
                     labels = scales::number_format(accuracy = 1000)) +
  scale_color_manual(values = c("Negativo" = "#55f5cc", 
                                "Control" = "#041b9b", 
                                "FFSS" = "#70044e"))

Grafica_amplif_equipo