Ra223 - Analisis expresion pre y post ADT

Author

Juan Bizzotto, PhD

Published

February 21, 2024

Grafico Version 1:

lineas conectoras y prueba de t pareada (wilcox)

Grafico Version 2

todas las comparaciones posibles

Code
# METODO CON STAT_COMPARE_MENAS
#hacer los graficos con lineas conectoras y prueba de t pareada (wilcox)

genes_int = genes.a.usar


for (i in 1:length(genes_int)){
  # preparo la data
  gen = genes_int[i]
  exp.gen = exp[,gen]
  exp.gen.l = log2(exp.gen + 1)
  grupo = clin$grupo
  experimento = clin$Experimento
  pacientes = clin$Paciente
  datitos = data.frame(grupo, experimento, exp.gen, exp.gen.l, pacientes )
  
  data.stat.paired = datitos %>% filter(experimento %in% c('PRJNA209978','PRJNA219507'))
  exp.pre = data.stat.paired %>% arrange(pacientes) %>% filter(grupo == 'Primary Tumor') %>% dplyr::select(exp.gen)
  exp.pre = as.numeric(exp.pre$exp.gen)
  exp.post = data.stat.paired %>% arrange(pacientes) %>% filter(grupo == 'Primary post ADT') %>% dplyr::select(exp.gen)
  exp.post = as.numeric(exp.post$exp.gen)
  genstat = wilcox.test(exp.pre, exp.post, paired = T)

  # grafico
  ploteo = ggplot(data = datitos %>% filter(experimento %in% ensayos.quiero ), aes(x=grupo, y=exp.gen.l )) +
    geom_point(aes(color=experimento), size=2)+
    geom_line(aes(x  = grupo , y = exp.gen.l, group = pacientes), alpha = 0.5) +
    xlab(NULL) +
    ylab(paste(gen, "expression \n log2 (norm counts +1)")) +
    theme(legend.position = "bottom") +
    theme_bw() +
    theme(axis.text = element_text(size = 10),
          axis.title = element_text(size = 10),
          plot.title =element_text(size = 15),
          axis.text.x = element_text(angle = 45, hjust=1)) +#,
          #legend.position = 'none') +   # para sacar la leyenda
    stat_summary(fun=mean,
                 geom="point",
                 shape= '_',
                 size=10)
  # imprimo
    print(ploteo + 
            labs(title = gen, subtitle = " Se muestra la estadistica para todas las comparaciones posibles \n el valor numerico inferior es la prueba apareada entre pre y post ADT") +  
            ggplot2::annotate("text", x = 2.5, y = min(exp.gen.l)-1, label = paste(round(genstat$p.value, digits = 4)), size = 4) + 
            
           # stat_compare_means(label = "p.signif", method = 'wilcox.test' , ref.group = "Primary Tumor" )    
            stat_compare_means(comparisons = lista, label = "p.format" )   
            
            )  
    
    # lo agrego a pw
  
    # print(ploteo)
  # guardo el plot
  assign(paste(gen,'ploteo_DGE', sep = '_'), ploteo  )

}

Code
  # # grafico para uno solo
  # ploteo = ggplot(data = datitos %>% filter(experimento %in% ensayos.quiero ), aes(x=grupo, y=exp.gen.l )) +
  #   geom_point(aes(color=experimento), size=2)+
  #   geom_line(aes(x  = grupo , y = exp.gen.l, group = pacientes)) +
  #   xlab(NULL) +
  #   ylab(paste(gen, "expression \n log2 (norm counts +1)")) +
  #   theme(legend.position = "bottom") +
  #   theme_bw() +
  #   theme(axis.text = element_text(size = 10),
  #         axis.title = element_text(size = 10),
  #         plot.title =element_text(size = 15),
  #         axis.text.x = element_text(angle = 45, hjust=1)) +#,
  #         #legend.position = 'none') +   # para sacar la leyenda
  #   stat_summary(fun=mean,
  #                geom="point",
  #                shape= '_',
  #                size=10)
  # # imprimo
  #   print(ploteo)
  #   

Grafico Version 3:

solo comparaciones significativas