-
Notifications
You must be signed in to change notification settings - Fork 3
/
readme.Rmd
126 lines (95 loc) · 2.02 KB
/
readme.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
output: github_document
always_allow_html: yes
---
# cytoqc -- A standardization tool for openCyto
*cytoqc* checks and standardizes channels, markers, keywords, gates of the cytodata .
```{r include=FALSE}
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
library(knitr)
```
## Installation
```{r, eval=FALSE}
remotes::install_github("RGLab/cytoqc")
```
## Get started
```{r}
library(flowCore)
library(flowWorkspace)
library(cytoqc)
```
```{r include=FALSE}
# prepare the test data
data("GvHD")
fs <- GvHD[8:28]#exclude samples that has different Time length
data_dir <- tempfile()
dir.create(data_dir)
write.flowSet(fs, data_dir)
```
## Load the FCS
```{r}
files <- list.files(data_dir, ".fcs", full.names = TRUE)
cqc_data <- cqc_load_fcs(files)
cqc_data
```
```{r include=FALSE}
#simulate channel discrepancy
#case
cf <- cqc_data[[1]]
colnames(cf)[1] <- "fsc-h"
#missing
cqc_data[[1]] <- cf[,1:7]
#redundant
thisfile <- files[2]
fr <- read.FCS(thisfile)
new_col <- exprs(fr)[,8,drop=F]
colnames(new_col) <- "channelA"
fr <- fr_append_cols(fr, new_col)
write.FCS(fr, files[2])
cqc_data[[2]] <- load_cytoframe_from_fcs(thisfile, is_h5 = TRUE)
#typo
cf <- cqc_data[[2]]
colnames(cf)[2] <- "SSC1-H"
#both case and typo
cf <- cqc_data[[3]]
colnames(cf)[1:2] <- c("fsc-h", "SSC1-H")
#order
cf <- cqc_data[[4]]
cf_swap_colnames(cf, "FL1-H", "FL2-H")
```
## The basic workflow can be summarised as four steps:
1. check
2. match
3. fix
### 1. Check the consistency across samples
```{r}
check_results <- cqc_check(cqc_data, type = "channel")
check_results
```
### 2. Match the reference
```{r render=normal_print}
res <- cqc_match(check_results, ref = 3)
res
```
### 3. Apply the fix
```{r}
cqc_fix(res)
```
## Update check report
```{r}
check_results <- cqc_check(cqc_data, type = "channel")
check_results
```
## Return the cleaned data
```{r}
cqc_data <- cqc_get_data(check_results)
cqc_data
```
## Coerce it inot `cytoset`
```{r}
cytoset(cqc_data)
```
## Or output to FCS
```{r eval=FALSE}
cqc_write_fcs(cqc_data, outdir)
```