Skip to content

Commit

Permalink
Quitar lo de option(recount3_url)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcolladotor committed Feb 1, 2024
1 parent c70bfde commit 0f1b4b9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 41 deletions.
34 changes: 17 additions & 17 deletions 01_intro_rstudio.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## ----install_rsthemes, eval = FALSE--------------------------------------------------
## ----install_rsthemes, eval = FALSE----
## remotes::install_github(c(
## "gadenbuie/rsthemes"
## ))
## remotes::install_cran("suncalc")
## rsthemes::install_rsthemes(include_base16 = TRUE)


## ----r_profile, eval = FALSE---------------------------------------------------------
## ----r_profile, eval = FALSE-----------
## usethis::edit_r_profile()
##
## ## From https://www.garrickadenbuie.com/project/rsthemes/
Expand All @@ -32,21 +32,21 @@
## options(repos = c(CRAN = "https://cloud.r-project.org"))


## ----proj, eval = FALSE--------------------------------------------------------------
## ----proj, eval = FALSE----------------
## usethis::create_project("~/rnaseq_2024_notas")


## ----create_setup, eval = FALSE------------------------------------------------------
## ----create_setup, eval = FALSE--------
## ## Start a setup file
## usethis::use_r("01-notas.R")


## ----create_01-visualizar-mtcars, eval = FALSE---------------------------------------
## ----create_01-visualizar-mtcars, eval = FALSE----
## ## Creemos el archivo R/02-visualizar-mtcars.R
## usethis::use_r("02-visualizar-mtcars.R")


## ----vis_mtcars, eval = FALSE--------------------------------------------------------
## ----vis_mtcars, eval = FALSE----------
## library("sessioninfo")
## library("here")
## library("ggplot2")
Expand Down Expand Up @@ -75,29 +75,29 @@
## sessioninfo::session_info()


## ----use_git_init, eval = FALSE------------------------------------------------------
## ----use_git_init, eval = FALSE--------
## ## Para poder conectar tu compu con GitHub
## usethis::create_github_token() ## Abrirá una página web, escoje un nombre único
## ## y luego da click en el botón verde al final. Después copia el token
## ## (son 40 caracteres)


## ----gitcreds_set, eval = FALSE------------------------------------------------------
## ----gitcreds_set, eval = FALSE--------
## gitcreds::gitcreds_set() ## Ojo, copia el token, no tu password de git!
## ## Si no, terminaras en la situación descrita en
## ## https://github.com/r-lib/usethis/issues/1347


## ----edit_r_envir, eval = FALSE------------------------------------------------------
## ----edit_r_envir, eval = FALSE--------
## usethis::edit_r_environ()


## ----use_git_cont_parte1, eval = FALSE-----------------------------------------------
## ----use_git_cont_parte1, eval = FALSE----
## ## Configura tu usuario de GitHub
## usethis::edit_git_config()


## ----use_git_cont_parte2, eval = FALSE-----------------------------------------------
## ----use_git_cont_parte2, eval = FALSE----
## ## Para inicializar el repositorio de Git
## usethis::use_git()
##
Expand All @@ -112,7 +112,7 @@
## ## https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
## git clone [email protected]:lcolladotor/rnaseq_LCG-UNAM_2024.git

## ----clone_repo, eval = FALSE--------------------------------------------------------
## ----clone_repo, eval = FALSE----------
## ## Opción más nueva:
## library("gert")
## repo <- git_clone(
Expand All @@ -128,26 +128,26 @@
## )


## ----eval=FALSE----------------------------------------------------------------------
## ----eval=FALSE------------------------
## ## Puedes instalar Postcards con el siguiente comando:
## install.packages("postcards")
##
## ## O puedes instalar la última versión en desarrollo:
## remotes::install_github("seankross/postcards@main")


## ----eval=FALSE----------------------------------------------------------------------
## ----eval=FALSE------------------------
## ## Crearun nuevo proyecto
## usethis::create_project("Su_Usuario.github.io")


## ----eval=FALSE----------------------------------------------------------------------
## ----eval=FALSE------------------------
## ## Configurar Git y GitHub
## usethis::use_git() # Reiniciar la sesión
## usethis::use_github()


## ----eval=FALSE----------------------------------------------------------------------
## ----eval=FALSE------------------------
## ## Elegir solo una plantilla (la que más te guste)
## postcards::create_postcard(template = "jolla")
## postcards::create_postcard(template = "jolla-blue")
Expand All @@ -156,7 +156,7 @@
## postcards::create_postcard(template = "solana")


## ----eval=FALSE----------------------------------------------------------------------
## ----eval=FALSE------------------------
## ## Desplegar la página GitHub
## rmarkdown::render("index.Rmd")

42 changes: 20 additions & 22 deletions 05_modelos.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
## ----model.matrix--------------------------------------------------------------------
## ----model.matrix----------------------
## ?model.matrix
mat <- with(trees, model.matrix(log(Volume) ~ log(Height) + log(Girth)))
mat
colnames(mat)


## ----lm_example----------------------------------------------------------------------
## ----lm_example------------------------
summary(lm(log(Volume) ~ log(Height) + log(Girth), data = trees))


## ----EMM_example1--------------------------------------------------------------------
## ----EMM_example1----------------------
## Datos de ejemplo
(sampleData <- data.frame(
genotype = rep(c("A", "B"), each = 4),
Expand All @@ -27,7 +27,7 @@ vd <- ExploreModelMatrix::VisualizeDesign(
cowplot::plot_grid(plotlist = vd$plotlist)


## ----EMM_example1_interactive, eval = FALSE------------------------------------------
## ----EMM_example1_interactive, eval = FALSE----
## ## Usaremos shiny otra ves
## app <- ExploreModelMatrix(
## sampleData = sampleData,
Expand All @@ -36,11 +36,9 @@ cowplot::plot_grid(plotlist = vd$plotlist)
## if (interactive()) shiny::runApp(app)


## ----download_SRP045638--------------------------------------------------------------
## ----download_SRP045638----------------
library("recount3")

options(recount3_url = "https://recount-opendata.s3.amazonaws.com/recount3/release")

human_projects <- available_projects()

rse_gene_SRP045638 <- create_rse(
Expand All @@ -52,16 +50,16 @@ rse_gene_SRP045638 <- create_rse(
assay(rse_gene_SRP045638, "counts") <- compute_read_counts(rse_gene_SRP045638)


## ----describe_issue------------------------------------------------------------------
## ----describe_issue--------------------
rse_gene_SRP045638$sra.sample_attributes[1:3]


## ----solve_issue---------------------------------------------------------------------
## ----solve_issue-----------------------
rse_gene_SRP045638$sra.sample_attributes <- gsub("dev_stage;;Fetal\\|", "", rse_gene_SRP045638$sra.sample_attributes)
rse_gene_SRP045638$sra.sample_attributes[1:3]


## ----attributes----------------------------------------------------------------------
## ----attributes------------------------
rse_gene_SRP045638 <- expand_sra_attributes(rse_gene_SRP045638)

colData(rse_gene_SRP045638)[
Expand All @@ -70,7 +68,7 @@ colData(rse_gene_SRP045638)[
]


## ----re_cast-------------------------------------------------------------------------
## ----re_cast---------------------------
## Pasar de character a numeric o factor
rse_gene_SRP045638$sra_attribute.age <- as.numeric(rse_gene_SRP045638$sra_attribute.age)
rse_gene_SRP045638$sra_attribute.disease <- factor(tolower(rse_gene_SRP045638$sra_attribute.disease))
Expand All @@ -84,7 +82,7 @@ summary(as.data.frame(colData(rse_gene_SRP045638)[
]))


## ----new_variables-------------------------------------------------------------------
## ----new_variables---------------------
## Encontraremos diferencias entre muestra prenatalas vs postnatales
rse_gene_SRP045638$prenatal <- factor(ifelse(rse_gene_SRP045638$sra_attribute.age < 0, "prenatal", "postnatal"))
table(rse_gene_SRP045638$prenatal)
Expand All @@ -98,7 +96,7 @@ with(colData(rse_gene_SRP045638), plot(assigned_gene_prop, sra_attribute.RIN))
with(colData(rse_gene_SRP045638), tapply(assigned_gene_prop, prenatal, summary))


## ----filter_rse----------------------------------------------------------------------
## ----filter_rse------------------------
## Guardemos nuestro objeto entero por si luego cambiamos de opinión
rse_gene_SRP045638_unfiltered <- rse_gene_SRP045638

Expand Down Expand Up @@ -129,7 +127,7 @@ dim(rse_gene_SRP045638)
round(nrow(rse_gene_SRP045638) / nrow(rse_gene_SRP045638_unfiltered) * 100, 2)


## ----normalize-----------------------------------------------------------------------
## ----normalize-------------------------
library("edgeR") # BiocManager::install("edgeR", update = FALSE)
dge <- DGEList(
counts = assay(rse_gene_SRP045638, "counts"),
Expand All @@ -138,7 +136,7 @@ dge <- DGEList(
dge <- calcNormFactors(dge)


## ----explore_gene_prop_by_age--------------------------------------------------------
## ----explore_gene_prop_by_age----------
library("ggplot2")
ggplot(as.data.frame(colData(rse_gene_SRP045638)), aes(y = assigned_gene_prop, x = prenatal)) +
geom_boxplot() +
Expand All @@ -147,14 +145,14 @@ ggplot(as.data.frame(colData(rse_gene_SRP045638)), aes(y = assigned_gene_prop, x
xlab("Age Group")


## ----statiscal_model-----------------------------------------------------------------
## ----statiscal_model-------------------
mod <- model.matrix(~ prenatal + sra_attribute.RIN + sra_attribute.sex + assigned_gene_prop,
data = colData(rse_gene_SRP045638)
)
colnames(mod)


## ----run_limma-----------------------------------------------------------------------
## ----run_limma-------------------------
library("limma")
vGene <- voom(dge, mod, plot = TRUE)

Expand All @@ -179,7 +177,7 @@ volcanoplot(eb_results, coef = 2, highlight = 3, names = de_results$gene_name)
de_results[de_results$gene_name %in% c("ZSCAN2", "VASH2", "KIAA0922"), ]


## ----pheatmap------------------------------------------------------------------------
## ----pheatmap--------------------------
## Extraer valores de los genes de interés
exprs_heatmap <- vGene$E[rank(de_results$adj.P.Val) <= 50, ]

Expand All @@ -200,7 +198,7 @@ pheatmap(
)


## ----plot_mds------------------------------------------------------------------------
## ----plot_mds--------------------------
## Para colores
library("RColorBrewer")

Expand All @@ -221,7 +219,7 @@ col.sex <- as.character(col.sex)
plotMDS(vGene$E, labels = df$Sex, col = col.sex)


## ----respuesta, out.height="1100px"--------------------------------------------------
## ----respuesta, out.height="1100px"----
## Tenemos que usar gene_id y gene_name
rowRanges(rse_gene_SRP045638)

Expand Down Expand Up @@ -275,7 +273,7 @@ pheatmap(
dev.off()


## ----"centered_and_scaled", out.height="1100px"--------------------------------------
## ----"centered_and_scaled", out.height="1100px"----
## Versión con centering y scaling en los renglones (los genes)
pheatmap::pheatmap(
exprs_heatmap,
Expand All @@ -288,7 +286,7 @@ pheatmap::pheatmap(
)


## ----"complexheatmap", out.height="1100px"-------------------------------------------
## ----"complexheatmap", out.height="1100px"----
## Misma versión pero ahora con ComplexHeatmap en vez del paquete pheatmap
ComplexHeatmap::pheatmap(
exprs_heatmap,
Expand Down
2 changes: 0 additions & 2 deletions 05_modelos.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ Vamos a usar datos de https://www.ncbi.nlm.nih.gov/sra/?term=SRP045638 procesado
```{r download_SRP045638}
library("recount3")
options(recount3_url = "https://recount-opendata.s3.amazonaws.com/recount3/release")
human_projects <- available_projects()
rse_gene_SRP045638 <- create_rse(
Expand Down

0 comments on commit 0f1b4b9

Please sign in to comment.