#install.packages("pacman")
library("pacman")

p_load("readr",
       "dplyr",
       "ggplot2")
PCR <- read.csv(file="https://raw.githubusercontent.com/ManuelLaraMVZ/Transcript-mica/main/datos_miRNAs.csv")

PCR
Gen_ref <- PCR %>% 
filter(Condicion == "Control")  %>% 
  select(-2) %>% 
  filter(Gen == "U6 snRNA-001973")

Gen_ref
Gen_int <- PCR %>% 
  filter(Condicion == "Target") %>% 
  select(-2)
Gen_int
Mean_ref <- Gen_ref %>% 
  mutate(Prom_Cx=(Cx1+Cx2+Cx3)/3, 
         Prom_Tx = (T1+T2+T3)/3) %>% 
  select("Gen", "Prom_Cx", "Prom_Tx") #Es para que salga una tabla solo con lo que queremos

Mean_ref
Mean_int <- Gen_int %>% 
  mutate(Prom_Cx=(Cx1+Cx2+Cx3)/3, 
         Prom_Tx = (T1+T2+T3)/3) %>% 
  select("Gen", "Prom_Cx", "Prom_Tx") #Es para que salga una tabla solo con lo que queremos

Mean_int
Analisis <- Mean_int %>% 
  mutate(DCT_Cx =Mean_int$Prom_Cx-Mean_ref$Prom_Cx,
         DCT_Tx = Mean_int$Prom_Tx-Mean_ref$Prom_Tx,
         DosDCT_Cx = 2^-(DCT_Cx),
         DosDCT_Tx = 2^-(DCT_Tx),
         DosDDCT = DosDCT_Tx/DosDCT_Cx)
Analisis
Grafica_1 <- ggplot(Analisis,
                    mapping = aes(x = DosDCT_Cx,
                                  y = DosDCT_Tx))+
  geom_point(color = "#581")+
  theme_minimal()+
  labs(title = "Cambios de expresión de miRNAs",
       subtitle = "Gráfica de dispersión",
       caption = "Creó: Sofía Cota Mendoza",
       x= "Condición control (2^-DCt)",
       y= "Tratamiento (2^-DCt)")+
  geom_smooth(method = "lm",
              color = "#520",
              alpha = 0.05,
              linewidth = 0.5)

Grafica_1
## `geom_smooth()` using formula = 'y ~ x'