chunks: Ctrl+Alt+I, o Comand+Option+I se realizará un ejemplo de análisis de datos
install.packages("pacman")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.5'
## (as 'lib' is unspecified)
library ("pacman")
p_load("ggplot2", "dplyr", "vroom")
llama a base de datos
Datos_PCR <- vroom(file="https://raw.githubusercontent.com/ManuelLaraMVZ/resultados_PCR_practica/refs/heads/main/Genes.csv")
## Rows: 7 Columns: 7
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Gen
## dbl (6): C1, C2, C3, 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.
Datos_PCR
## # A tibble: 7 × 7
## Gen C1 C2 C3 T1 T2 T3
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 B-actina 19 19.5 18.9 18.5 18.8 18.2
## 2 PIF1 22.4 22 21 28 28.2 27.9
## 3 PLK1 22 21.8 21.6 21.7 21 21.5
## 4 CCNB1 30.1 31.2 30.8 25.2 25.2 25.3
## 5 PCNA 20 20.3 20.2 24 24.2 NA
## 6 CCNB2 33 NA 33.1 24 25 26
## 7 BRCA 21 20.5 20.4 19.1 19.2 19.5
aislar los genes de referencia de cada condición
Gen_ref <- Datos_PCR %>%
filter(Gen == "B-actina") #== significa "que diga exactamente igual"
Gen_ref
## # A tibble: 1 × 7
## Gen C1 C2 C3 T1 T2 T3
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 B-actina 19 19.5 18.9 18.5 18.8 18.2
generar base de datos con genes de interés
Gen_int <- Datos_PCR %>%
filter(Gen != "B-actina") #!= significa menos la fila de la actina
Gen_int
## # A tibble: 6 × 7
## Gen C1 C2 C3 T1 T2 T3
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 PIF1 22.4 22 21 28 28.2 27.9
## 2 PLK1 22 21.8 21.6 21.7 21 21.5
## 3 CCNB1 30.1 31.2 30.8 25.2 25.2 25.3
## 4 PCNA 20 20.3 20.2 24 24.2 NA
## 5 CCNB2 33 NA 33.1 24 25 26
## 6 BRCA 21 20.5 20.4 19.1 19.2 19.5
análisis
DCT <- Gen_int %>% #restar el gen de referencia a los GOI
mutate(DC1 = C1 - Gen_ref$C1,
DC2 = C2 - Gen_ref$C2,
DC3 = C3 - Gen_ref$C3,
DT1 = T1 - Gen_ref$T1,
DT2 = T2 - Gen_ref$T2,
DT3 = T3 - Gen_ref$T3) %>% #mutate crea nuevas columnas, $ es para seleccionar esa columma de esa base de datos
mutate(DosDCTC1 = 2^-DC1,
DosDCTC2 = 2^-DC2,
DosDCTC3 = 2^-DC3,
DosDCTT1 = 2^-DT1,
DosDCTT2 = 2^-DT2,
DosDCTT3 = 2^-DT3,) %>%
#dividir tx entre la situación control, pero hay por triplicado, hay que sacar el promedio del Cx y Tx
mutate (DosDCTCx = (DosDCTC1+DosDCTC2+DosDCTC3)/3,
DosDCTTx = (DosDCTT1+DosDCTT2+DosDCTT3)/3) %>%
#hacer la división tx/cx
mutate (DosDDCT = DosDCTTx/DosDCTCx)
DCT
## # A tibble: 6 × 22
## Gen C1 C2 C3 T1 T2 T3 DC1 DC2 DC3 DT1 DT2 DT3
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 PIF1 22.4 22 21 28 28.2 27.9 3.4 2.5 2.08 9.5 9.45 9.7
## 2 PLK1 22 21.8 21.6 21.7 21 21.5 3 2.3 2.68 3.2 2.25 3.3
## 3 CCNB1 30.1 31.2 30.8 25.2 25.2 25.3 11.1 11.7 11.9 6.7 6.45 7.1
## 4 PCNA 20 20.3 20.2 24 24.2 NA 1 0.800 1.28 5.5 5.45 NA
## 5 CCNB2 33 NA 33.1 24 25 26 14 NA 14.2 5.5 6.25 7.8
## 6 BRCA 21 20.5 20.4 19.1 19.2 19.5 2 1 1.48 0.600 0.450 1.3
## # ℹ 9 more variables: DosDCTC1 <dbl>, DosDCTC2 <dbl>, DosDCTC3 <dbl>,
## # DosDCTT1 <dbl>, DosDCTT2 <dbl>, DosDCTT3 <dbl>, DosDCTCx <dbl>,
## # DosDCTTx <dbl>, DosDDCT <dbl>
aislar datos
Datos_grafica <- DCT %>%
select("Gen","DosDDCT")
Datos_grafica
## # A tibble: 6 × 2
## Gen DosDDCT
## <chr> <dbl>
## 1 PIF1 0.00790
## 2 PLK1 0.869
## 3 CCNB1 27.7
## 4 PCNA NA
## 5 CCNB2 NA
## 6 BRCA 1.62
grafica
Grafica_PCR <- ggplot(Datos_grafica,
aes(x = Gen,
y = DosDDCT))+
geom_col()+
theme_classic()
Grafica_PCR
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_col()`).
gráfica regresión lineal: necesita nombres de genes, promedios de
2^-deltaCT de cx y tx ctrl+shift+m: magrritr
Datos_regresion <- DCT %>%
select("Gen", "DosDCTCx", "DosDCTTx")
Datos_regresion
## # A tibble: 6 × 3
## Gen DosDCTCx DosDCTTx
## <chr> <dbl> <dbl>
## 1 PIF1 0.169 0.00134
## 2 PLK1 0.161 0.140
## 3 CCNB1 0.000340 0.00945
## 4 PCNA 0.495 NA
## 5 CCNB2 NA 0.0132
## 6 BRCA 0.369 0.599
graficar regresión lineal
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'
## Warning: Removed 2 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).