library("dplyr")
library("tidyr")
library("pheatmap")
counts.df <- read.csv(file = "rpkm_embryonic_day3vsday7.csv", row.names = 1)
head(counts.df)
counts_with_names.df <- counts.df %>%
mutate(gene_name = rownames(counts.df))
###¢ Cargar genes up y down regulated
upregulated.df <- read.csv(file = "genes_upregulated.csv", header = TRUE, row.names = 1)
downregulated.df <- read.csv(file = "genes_downregulated.csv", header = TRUE, row.names = 1)
set.seed(77)
allDE.df <- rbind(upregulated.df, downregulated.df) %>%
sample_n(size = 100) %>%
arrange(desc(State),
desc(norm_total_mean_1),
desc(norm_foldChange))
DE_names.df <- allDE.df %>%
select(gene_name)
DE_counts.df <- DE_names.df %>%
left_join(counts_with_names.df, by= "gene_name")
rownames(DE_counts.df) <- DE_counts.df$gene_name
only_counts.df <- DE_counts.df %>%
select(-gene_name)
El nombre de las filas deben ser los genes y el nombre de las columnas debe ser la muestra
pheat_A.p <- pheatmap(mat = only_counts.df,
main = "Single cell counts - Defaults",
)
library("RColorBrewer")
mi_escala.v <- colorRampPalette(c("darkblue", "white", "red")) (100)
pheat_B.p <- pheatmap(mat = only_counts.df,
main = "Single cell counts - otro color gradiente",
color = mi_escala.v
)
pheat_C.p <- pheatmap(mat = only_counts.df,
main = "Single cell counts - otro color gradiente",
color = mi_escala.v,
scale = "row"
)
pheat_D.p <- pheatmap(mat = only_counts.df,
main = "Single cell counts - otro color gradiente",
color = mi_escala.v,
scale = "row",
show_rownames = F,
show_colnames = F
)
cell_ids.df <- read.csv(file = "celulas_etiquetadas.csv")
rownames(cell_ids.df) <- cell_ids.df$column_names
etiquetas_final.df <- cell_ids.df %>%
select(tag)
genes_etiquetados.df <- allDE.df %>%
select(State)
mis_colores.v <- list(tag = c( "E3" = "#C59B76", "E7" = "#9F84BD"), # la columna tag del dataframe etiquetas_final.df
State = c("up" = "#78BC61", "down" = "#E9806E")
)
pheat_E.p <- pheatmap(mat = only_counts.df,
main = "Single cell counts - otro color gradiente",
color = mi_escala.v,
scale = "row",
show_rownames = F,
show_colnames = F,
annotation_colors = mis_colores.v,
annotation_row = genes_etiquetados.df
)
pheat_F.p <- pheatmap(mat = only_counts.df,
main = "Single cell counts - otro color gradiente",
color = mi_escala.v,
scale = "row",
show_rownames = F,
show_colnames = F,
annotation_colors = mis_colores.v,
annotation_row = genes_etiquetados.df,
annotation_col = etiquetas_final.df
)
pheat_F.p <- pheatmap(mat = only_counts.df,
main = "Single cell counts - otro color gradiente",
color = mi_escala.v,
scale = "row",
show_rownames = F,
show_colnames = F,
annotation_colors = mis_colores.v,
annotation_row = genes_etiquetados.df,
annotation_col = etiquetas_final.df,
cluster_rows = F,
cluster_cols = F
)
# library(ggplot2)
#
# plots.v <- apropos("pheat_")
#
# n_plots <- length(plots.v)
#
# for ( i in 1:n_plots) {
# plots_en_turno <- plots.v[i]
#
# ggsave(filename = paste0(plot_en_turno, ".png"),
# plot = get(plots_en_turno),
# height = 14,
# width = 14,
# units = "in",
# dpi = 300 )
# }