You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
3.0 KiB

7 months ago
  1. library(tidyverse)
  2. library(flowWorkspace)
  3. library(Biobase)
  4. library(flowGate)
  5. source("functionsCyto.R")
  6. files<-list.files("Files", pattern = ".LMD", full.names = T)
  7. LMD2FCS(files)
  8. fs<-read.ncdfFlowSet(files=list.files("Files",".fcs", full.names = T), readonly = F)
  9. gs <- GatingSet(fs)
  10. comp<-as.matrix(read.csv("CompMatrix.csv", check.names = F, row.names = 1))
  11. gs<-compensate(gs, comp)
  12. trans_params<-transform_gs(gs)
  13. saveRDS(trans_params, "trans_params.rds")
  14. trans_params<-readRDS("trans_params.rds")
  15. trans_apply(gs, trans_params = trans_params)
  16. colnames(gs)[c(4,6,11)]<-c("CD16","CD56","CD107a")
  17. sampleNames(gs)<-gsub("\\s[0-9]*.fcs","",sampleNames(gs))
  18. sampleNames(gs)<-gsub(".*\\s","",sampleNames(gs))
  19. pData(gs)$name<-rownames(pData(gs))
  20. gates<-list()
  21. gs_gate_interactive(gs,
  22. filterId = "Leukocytes",
  23. dims = list("FS-A", "SS-A"))
  24. gates[["Leukocytes"]]<-gs_pop_get_gate(gs, "Leukocytes")
  25. gs_gate_interactive(gs,
  26. subset = "Leukocytes",
  27. filterId = "NKdim",
  28. dims = list("CD16", "CD56"))
  29. gates[["NKdim"]]<-gs_pop_get_gate(gs, "NKdim")
  30. gs_gate_interactive(gs[["NKs-K562"]],
  31. subset = "NKdim",
  32. filterId = "CD107a+",
  33. dims = list("CD107a", "CD56"), overlayGates = "CD107a+")
  34. gates[["CD107a+"]]<-gs_pop_get_gate(gs, "CD107a+")
  35. gates<-gates_save(gs, file = "gates.rds")
  36. gates<-readRDS("gates.rds")
  37. gs<-gates_apply(gs, gates)
  38. autoplot(gs, "CD107a+")
  39. ggcyto_trans(gs, "CD107a", "CD56", subset="NKdim")
  40. autoplot(gs[[5]], bins=0)
  41. ggcyto_trans_all(gs, index = 5, ncol=1)
  42. stats<-gs_pop_get_stats(gs, nodes="CD107a+", type="perc")
  43. ggpubr::ggarrange(
  44. ggcyto_trans_all(gs, nrow=1),
  45. ggcyto::as.ggplot(ggcyto_trans(gs, "CD107a", "CD56", subset="NKdim")+
  46. facet_grid(.~name)),
  47. ggplot(stats, aes(sample, percent))+
  48. geom_bar(stat="identity", color="black", fill="grey70"),
  49. ncol=1)
  50. ggsave("Analysis.jpg")
  51. save_gs(gs, "gs_analysis")
  52. gs<-load_gs("gs_analysis/")
  53. ## For a new experiment with same settings
  54. files<-list.files("Files", pattern = ".LMD", full.names = T)
  55. LMD2FCS(files)
  56. fs<-read.ncdfFlowSet(files=list.files("Files",".fcs", full.names = T), readonly = F)
  57. gs <- GatingSet(fs)
  58. comp<-as.matrix(read.csv("CompMatrix.csv", check.names = F, row.names = 1))
  59. gs<-compensate(gs, comp)
  60. trans_params<-readRDS("trans_params.rds")
  61. trans_apply(gs, trans_params = trans_params)
  62. colnames(gs)[c(4,6,11)]<-c("CD16","CD56","CD107a")
  63. sampleNames(gs)<-gsub("\\s[0-9]*.fcs","",sampleNames(gs))
  64. sampleNames(gs)<-gsub(".*\\s","",sampleNames(gs))
  65. pData(gs)$name<-rownames(pData(gs))
  66. gates<-readRDS("gates.rds")
  67. gs<-gates_apply(gs, gates) #if not the same gates, apply a general with "exact=F"
  68. stats<-gs_pop_get_stats(gs, nodes="CD107a+", type="perc")
  69. ggpubr::ggarrange(
  70. ggcyto_trans_all(gs, nrow=1),
  71. ggcyto::as.ggplot(ggcyto_trans(gs, "CD107a", "CD56", subset="NKdim")+
  72. facet_grid(.~name)),
  73. ggplot(stats, aes(sample, percent))+
  74. geom_bar(stat="identity", color="black", fill="grey70"),
  75. ncol=1)
  76. ggsave("Analysis.jpg")
  77. save_gs(gs, "gs_analysis")
  78. gs<-load_gs("gs_analysis/")