if(!require("pacman"))
install.packages("pacman")
## Cargando paquete requerido: pacman
## Warning: package 'pacman' was built under R version 4.5.2
p_load("ggplot2",
"dplyr",
"vroom",
"matrixTests")
Datos_PCR <- vroom(file="https://raw.githubusercontent.com/ManuelLaraMVZ/Transcript-mica/refs/heads/main/datos_miRNAs.csv")
## Rows: 363 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): Gen, Condicion
## dbl (6): Cx1, Cx2, Cx3, T1, T2, T3
##
## ℹ 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.
Gen_ref <- Datos_PCR %>%
filter(Gen == "U6 snRNA-001973")
Gen_ref
## # A tibble: 1 × 8
## Gen Condicion Cx1 Cx2 Cx3 T1 T2 T3
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 U6 snRNA-001973 Control 13.8 11.7 11.9 13.2 13.0 12.6
Gen_int <- Datos_PCR %>%
filter(Gen !="U6 snRNA-001973")
Gen_int
## # A tibble: 362 × 8
## Gen Condicion Cx1 Cx2 Cx3 T1 T2 T3
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 ath-miR159a-000338 Target 35 35 35 35 35 35
## 2 hsa-let-7a-000377 Target 20.5 21.0 21.0 20.4 19.6 20.9
## 3 hsa-let-7b-002619 Target 18.4 19.0 19.1 18.3 17.4 19.0
## 4 hsa-let-7c-000379 Target 22.2 23.7 23.8 22.9 22.0 24.0
## 5 hsa-let-7d-002283 Target 22.2 22.7 21.9 22.0 21.2 21.9
## 6 hsa-let-7e-002406 Target 18.0 18.4 18.5 18.0 17.3 18.6
## 7 hsa-let-7f-000382 Target 24.4 25.2 24.7 23.8 23.0 24.9
## 8 hsa-let-7g-002282 Target 22.1 22.1 22.5 22.3 22.0 22.8
## 9 hsa-miR-1-002222 Target 31.4 32.9 32.5 33.0 31.8 33.6
## 10 hsa-miR-100-000437 Target 17.2 16.4 16.3 16.9 17.0 16.0
## # ℹ 352 more rows
DCT <- Gen_int %>%
mutate(DC1 = Cx1 - Gen_ref$Cx1,
DC2 = Cx2 - Gen_ref$Cx2,
DC3 = Cx3 - Gen_ref$Cx3,
DT1 = T1 - Gen_ref$T1,
DT2 = T2 - Gen_ref$T2,
DT3 = T3 - Gen_ref$T3) %>%
mutate (DosDCTCx1 =2^-DC1,
DosDCTCx2 =2^-DC2,
DosDCTCx3 =2^-DC3,
DosDCTT1 =2^-DT1,
DosDCTT2 =2^-DT2,
DosDCTT3 =2^-DT3
) %>%
mutate(DosDCTCx = (DosDCTCx1+DosDCTCx2+DosDCTCx3)/3,
DosDCTTx = (DosDCTT1+DosDCTT2+DosDCTT3)/3) %>%
mutate(DosDDCT = DosDCTTx/DosDCTCx)
DCT
## # A tibble: 362 × 23
## Gen Condicion Cx1 Cx2 Cx3 T1 T2 T3 DC1 DC2 DC3 DT1
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 ath-mi… Target 35 35 35 35 35 35 21.2 23.3 23.1 21.8
## 2 hsa-le… Target 20.5 21.0 21.0 20.4 19.6 20.9 6.70 9.26 9.08 7.19
## 3 hsa-le… Target 18.4 19.0 19.1 18.3 17.4 19.0 4.56 7.29 7.21 5.06
## 4 hsa-le… Target 22.2 23.7 23.8 22.9 22.0 24.0 8.39 11.9 11.8 9.72
## 5 hsa-le… Target 22.2 22.7 21.9 22.0 21.2 21.9 8.40 10.9 9.94 8.78
## 6 hsa-le… Target 18.0 18.4 18.5 18.0 17.3 18.6 4.18 6.65 6.54 4.82
## 7 hsa-le… Target 24.4 25.2 24.7 23.8 23.0 24.9 10.6 13.4 12.7 10.6
## 8 hsa-le… Target 22.1 22.1 22.5 22.3 22.0 22.8 8.29 10.4 10.6 9.09
## 9 hsa-mi… Target 31.4 32.9 32.5 33.0 31.8 33.6 17.6 21.2 20.5 19.8
## 10 hsa-mi… Target 17.2 16.4 16.3 16.9 17.0 16.0 3.39 4.63 4.33 3.72
## # ℹ 352 more rows
## # ℹ 11 more variables: DT2 <dbl>, DT3 <dbl>, DosDCTCx1 <dbl>, DosDCTCx2 <dbl>,
## # DosDCTCx3 <dbl>, DosDCTT1 <dbl>, DosDCTT2 <dbl>, DosDCTT3 <dbl>,
## # DosDCTCx <dbl>, DosDCTTx <dbl>, DosDDCT <dbl>
Datos_grafica <- DCT %>%
select("Gen", "DosDDCT")
Datos_grafica
## # A tibble: 362 × 2
## Gen DosDDCT
## <chr> <dbl>
## 1 ath-miR159a-000338 1.10
## 2 hsa-let-7a-000377 1.54
## 3 hsa-let-7b-002619 1.57
## 4 hsa-let-7c-000379 1.00
## 5 hsa-let-7d-002283 1.59
## 6 hsa-let-7e-002406 1.34
## 7 hsa-let-7f-000382 2.09
## 8 hsa-let-7g-002282 1.01
## 9 hsa-miR-1-002222 0.613
## 10 hsa-miR-100-000437 1.28
## # ℹ 352 more rows
Grafica_PCR <- ggplot(Datos_grafica,
aes(x = Gen,
y = DosDDCT)) + # fill por Gen para colores distintos
geom_col() +
labs(title = "Expresión relativa de genes",
subtitle = "Normalización con B-actina como referencia") +
theme_minimal(base_size = 14) + # estilo minimalista
theme(plot.background = element_rect(fill = "white", color = NA),
panel.background = element_rect(fill = "white", color = NA)) +
scale_fill_brewer(palette = "Set3") # paleta con colores distintos
Grafica_PCR

Datos_regresion <- DCT %>%
select("Gen", "DosDCTCx", "DosDCTTx")
Datos_regresion
## # A tibble: 362 × 3
## Gen DosDCTCx DosDCTTx
## <chr> <dbl> <dbl>
## 1 ath-miR159a-000338 0.000000209 0.000000230
## 2 hsa-let-7a-000377 0.00436 0.00670
## 3 hsa-let-7b-002619 0.0185 0.0289
## 4 hsa-let-7c-000379 0.00117 0.00117
## 5 hsa-let-7d-002283 0.00150 0.00238
## 6 hsa-let-7e-002406 0.0253 0.0338
## 7 hsa-let-7f-000382 0.000290 0.000605
## 8 hsa-let-7g-002282 0.00153 0.00155
## 9 hsa-miR-1-002222 0.00000202 0.00000124
## 10 hsa-miR-100-000437 0.0618 0.0789
## # ℹ 352 more rows
Grafica_regresion <- ggplot(Datos_regresion,
aes(x = DosDCTCx, y = DosDCTTx)) +
geom_point(color = "steelblue", size = 3, alpha = 0.7) + # puntos más visibles
geom_abline(intercept = 0, slope = 1, # línea con pendiente 1
color = "red", linetype = "dashed", size = 1) +
geom_smooth(method = "lm", se = FALSE, color = "darkgreen") +
labs(title = "Comparación de DosDCTCx vs DosDCTTx",
x = "DosDCTCx",
y = "DosDCTTx") +
theme_minimal(base_size = 14) + # estilo limpio
theme(plot.title = element_text(hjust = 0.5, face = "bold")) # título centrado
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
Grafica_regresion
## `geom_smooth()` using formula = 'y ~ x'

Datos_estadistica <- DCT %>%
select(Gen,
DosDCTCx1, DosDCTCx2, DosDCTCx3, DosDCTT1, DosDCTT2, DosDCTT3)
head(Datos_estadistica)
## # A tibble: 6 × 7
## Gen DosDCTCx1 DosDCTCx2 DosDCTCx3 DosDCTT1 DosDCTT2 DosDCTT3
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 ath-miR159a-000338 0.000000412 9.99e-8 1.14e-7 2.73e-7 2.31e-7 1.86e-7
## 2 hsa-let-7a-000377 0.00959 1.63e-3 1.85e-3 6.86e-3 1.01e-2 3.19e-3
## 3 hsa-let-7b-002619 0.0423 6.40e-3 6.77e-3 3.00e-2 4.44e-2 1.25e-2
## 4 hsa-let-7c-000379 0.00298 2.53e-4 2.71e-4 1.19e-3 1.94e-3 3.84e-4
## 5 hsa-let-7d-002283 0.00296 5.11e-4 1.02e-3 2.28e-3 3.28e-3 1.59e-3
## 6 hsa-let-7e-002406 0.0553 9.98e-3 1.08e-2 3.55e-2 4.95e-2 1.66e-2
Prueba_t <- row_t_welch(Datos_estadistica [,c("DosDCTCx1", "DosDCTCx2", "DosDCTCx3")], Datos_estadistica [,c("DosDCTT1", "DosDCTT2", "DosDCTT3")])
head(Prueba_t)
## obs.x obs.y obs.tot mean.x mean.y mean.diff var.x
## 1 3 3 6 2.085781e-07 2.301129e-07 -2.153484e-08 3.119115e-14
## 2 3 3 6 4.358470e-03 6.703629e-03 -2.345159e-03 2.055696e-05
## 3 3 3 6 1.847955e-02 2.894885e-02 -1.046930e-02 4.246503e-04
## 4 3 3 6 1.169435e-03 1.171796e-03 -2.360368e-06 2.468648e-06
## 5 3 3 6 1.497706e-03 2.383400e-03 -8.856939e-04 1.672101e-06
## 6 3 3 6 2.533496e-02 3.384471e-02 -8.509754e-03 6.719916e-04
## var.y stderr df statistic pvalue conf.low
## 1 1.893963e-15 1.050160e-07 2.241992 -0.205062330 0.8546600 -4.297181e-07
## 2 1.179928e-05 3.284116e-03 3.726966 -0.714091575 0.5173308 -1.173291e-02
## 3 2.556888e-04 1.505921e-02 3.767623 -0.695209149 0.5274084 -5.331729e-02
## 4 6.078987e-07 1.012677e-03 2.928677 -0.002330819 0.9982899 -3.270011e-03
## 5 7.252888e-07 8.939407e-04 3.460287 -0.990774793 0.3859209 -3.528059e-03
## 6 2.733314e-04 1.775127e-02 3.396028 -0.479388378 0.6608666 -6.145216e-02
## conf.high mean.null alternative conf.level
## 1 3.866485e-07 0 two.sided 0.95
## 2 7.042588e-03 0 two.sided 0.95
## 3 3.237869e-02 0 two.sided 0.95
## 4 3.265290e-03 0 two.sided 0.95
## 5 1.756671e-03 0 two.sided 0.95
## 6 4.443266e-02 0 two.sided 0.95
Datos_estadistica2 <- Datos_estadistica %>%
mutate(VP = Prueba_t$pvalue, FC = DCT$DosDDCT,
LogFC = log2(FC), LogVP = -log10(VP))
Datos_estadistica2
## # A tibble: 362 × 11
## Gen DosDCTCx1 DosDCTCx2 DosDCTCx3 DosDCTT1 DosDCTT2 DosDCTT3 VP FC
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 ath-miR… 4.12e-7 9.99e-8 1.14e-7 2.73e-7 2.31e-7 1.86e-7 0.855 1.10
## 2 hsa-let… 9.59e-3 1.63e-3 1.85e-3 6.86e-3 1.01e-2 3.19e-3 0.517 1.54
## 3 hsa-let… 4.23e-2 6.40e-3 6.77e-3 3.00e-2 4.44e-2 1.25e-2 0.527 1.57
## 4 hsa-let… 2.98e-3 2.53e-4 2.71e-4 1.19e-3 1.94e-3 3.84e-4 0.998 1.00
## 5 hsa-let… 2.96e-3 5.11e-4 1.02e-3 2.28e-3 3.28e-3 1.59e-3 0.386 1.59
## 6 hsa-let… 5.53e-2 9.98e-3 1.08e-2 3.55e-2 4.95e-2 1.66e-2 0.661 1.34
## 7 hsa-let… 6.32e-4 9.17e-5 1.46e-4 6.63e-4 9.52e-4 1.99e-4 0.324 2.09
## 8 hsa-let… 3.19e-3 7.49e-4 6.58e-4 1.83e-3 1.93e-3 8.84e-4 0.990 1.01
## 9 hsa-miR… 4.99e-6 4.20e-7 6.61e-7 1.11e-6 2.12e-6 4.89e-7 0.658 0.613
## 10 hsa-miR… 9.51e-2 4.05e-2 4.98e-2 7.61e-2 6.02e-2 1.00e-1 0.457 1.28
## # ℹ 352 more rows
## # ℹ 2 more variables: LogFC <dbl>, LogVP <dbl>
V_plot <- ggplot(Datos_estadistica2, aes(x = LogFC, y = LogVP))+
geom_point()+
labs(title = "Grafica de vulcano",
subtitle = "Datos genes 2 condiciones",
caption = "Diseño: Juana Rosetti",
x = "Log2 (2ˆDDCt)",
y = "-Log10 (p value)")
V_plot

# Definir los puntos con colores según las condiciones
Datos_estadistica2$color <- ifelse(Datos_estadistica2$LogVP > -log10(0.05) & Datos_estadistica2$LogFC > 1.5, "#ffbf70",
ifelse(Datos_estadistica2$LogVP > -log10(0.05) & Datos_estadistica2$LogFC < -1.5, "#7d7fe3",
ifelse(Datos_estadistica2$LogVP > -log10(0.05), "#e37dc9", "grey")))
# Graficar
V_plot <- ggplot(Datos_estadistica2,
aes(x = LogFC, y = LogVP, color = color)) +
geom_point() +
scale_color_identity() + # Usa los colores definidos sin leyenda extra
labs(title = "Gráfica de Vulcano",
subtitle = "Datos miRNAs condiciones",
caption = "Diseño: Juana Rosetti",
x = "Log2(2^DDCt)",
y = "-Log10(Valor p)") +
geom_hline(yintercept = -log10(0.05), linetype = "dashed") +
geom_vline(xintercept = 1.5, linetype = "dashed") +
geom_vline(xintercept = -1.5, linetype = "dashed")
V_plot
