#Command+option+i para el chunk

install.packages("pacman")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
library("pacman")

p_load("readr","dplyr","ggplot2")
PCR <- read.csv(file="https://raw.githubusercontent.com/ManuelLaraMVZ/Transcript-mica/main/datos_miRNAs.csv")
head(PCR)
PCR
Referencia <- PCR %>% 
  filter(Condicion == "Control") %>% select(-2) %>% 
  filter(Gen == "U6 snRNA-001973")
Referencia
Genes <- PCR %>% 
  filter(Condicion == "Target") %>% select(-2)
Genes
Mean_Ref <- Referencia %>% 
  mutate(Mean_Cx = (Cx1+Cx2+Cx3)/3, Mean_Tx = (T1+T2+T3)/3) %>% 
  select("Gen","Mean_Cx","Mean_Tx")

Mean_Ref
Mean_Gen <- Genes %>% 
  mutate(Mean_Cx = (Cx1+Cx2+Cx3)/3, Mean_Tx = (T1+T2+T3)/3) %>% 
  select("Gen","Mean_Cx","Mean_Tx")

Mean_Gen
Analisis <- Mean_Gen %>% 
mutate(DCt_Cx=Mean_Gen$Mean_Cx-Mean_Ref$Mean_Cx,
       DCt_Tx=Mean_Gen$Mean_Tx-Mean_Ref$Mean_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 = "#df3535") +
  theme_dark() + 
  labs(title = "Cambios de expresion de miRNAs",
       subtitle = "Gráfica de dispersión",
       caption = "Creo: Fernanda Hernández Rico",
       x = "Condición control (2^-DCt)",
       y = "Tratamiento (2^-DCt)")+
  geom_smooth(method = "lm",
              color = "#dfd535",
              alpha = 0.005,
              linewidth = 0.2)

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