Skip to content

Commit eed74e6

Browse files
author
bonagurol
committed
v0.1.5
1 parent ec28655 commit eed74e6

39 files changed

Lines changed: 2937 additions & 816 deletions

.Rhistory

Lines changed: 511 additions & 7 deletions
Large diffs are not rendered by default.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
condor.Rproj
33
.Rproj.user/
44
inst/doc
5-
.test_files
5+
.test_files
6+
docs
7+
.Rhistory

CHANGELOG

Lines changed: 0 additions & 41 deletions
This file was deleted.

DESCRIPTION

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
Package: condor
1+
Package: cyCONDOR
22
Type: Package
33
Title: Flow Cytometry data analysis toolbox
4-
Version: 0.1.4
4+
Version: 0.1.5
55
Author: Lorenzo Bonaguro
66
Maintainer: Lorenzo Bonaguro <lorenzobonaguro@uni-bonn.de>
77
Description: Flow cytometry analysis workflow. The aim of this project if to
88
provide an intuitive workflow for the analysis of high-dimensionality cytometry data in R.
9+
URL: https://github.com/lorenzobonaguro/condor
910
License: GPL-3 + file LICENSE
1011
Encoding: UTF-8
1112
LazyData: FALSE
13+
biocViews:
1214
Imports:
1315
ggplot2,
1416
RColorBrewer,
@@ -45,7 +47,8 @@ Imports:
4547
Hmisc,
4648
DelayedMatrixStats,
4749
cowplot,
48-
dplyr
50+
dplyr,
51+
reticulate
4952
RoxygenNote: 7.2.3
5053
VignetteBuilder: knitr
5154
Suggests:

NAMESPACE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ export(barplot_frequency)
77
export(boxplot_and_stats)
88
export(change_param_name)
99
export(check_IDs)
10+
export(clr)
1011
export(confusionMatrix)
1112
export(confusion_HM)
13+
export(densityplot_marker)
1214
export(df_frequency)
15+
export(dotplot_cyto)
1316
export(filter_fcd)
1417
export(harmonize_PCA)
1518
export(harmonize_intensities)
@@ -24,6 +27,8 @@ export(predict_labels)
2427
export(prepFcsFolderData)
2528
export(prep_fcd)
2629
export(prep_fjw)
30+
export(runAstir_cellstates)
31+
export(runAstir_celltype)
2732
export(runDM)
2833
export(runFlowSOM)
2934
export(runPCA)
@@ -65,9 +70,11 @@ import(randomForest)
6570
import(readr)
6671
import(readxl)
6772
import(reshape2)
73+
import(reticulate)
6874
import(slingshot)
6975
import(stringr)
7076
import(umap)
7177
importFrom(Matrix,sparseMatrix)
7278
importFrom(igraph,membership)
7379
importFrom(utils,packageDescription)
80+
importFrom(utils,write.csv)

NEWS.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# cyCONDOR 0.1.5
2+
3+
* Fix bug in the definition of tab separator when loading csv files
4+
* Added clr transformation for CITE-seq data together with minor improvements to the transformation function
5+
* Add clustering option in confusion matrix
6+
* Added visualization of 2D plots of PCA
7+
* Option to export plots as raster
8+
* Added function to plot conventional flow 2d plots
9+
* Added function to plot a density plot for marker expression
10+
* Implementation of Astir (with Python)
11+
* Restructured documentation and vignette
12+
* Added GitPages website with documentation and tutorials
13+
* Name change to `cyCONDOR`
14+
* Edited the pseudotime function to run in a loop for the starting clusters
15+
16+
# cyCONDOR 0.1.4
17+
18+
## Reference name: condor 0.1.4
19+
20+
* Add ML classifier with CytoML
21+
* Included Hmisc as requirment for Violin plto marker function
22+
* Fix bug with UMAP plotting function when faceting (default for facet_by_fariable set to FALSE not NULL)
23+
* Fixed package loading message
24+
* Tested diffusion map and imporoved function
25+
* Tested pseutodime and improved function
26+
* Splittied functions in multiple files to make them easier to find
27+
* Improved package documentation
28+
* Improved package vignette
29+
30+
# cyCONDOR 0.1.3
31+
32+
## Reference name: condor 0.1.3
33+
34+
* FlowSOM function can retain the model to plot the SOM tree afterwards
35+
* Added Function to read flowjo workspaces to a condor campatible format
36+
* Fixed filter function when the 'extra' slot is occupied
37+
38+
# cyCONDOR 0.1.2
39+
40+
## Reference name: condor 0.1.2
41+
42+
* Several bug fixes
43+
* Added function to calculate tSNE dimensionality reduction
44+
* Possibility to limit the number of PC used for clustering and non-linear dimensionality reduction
45+
* Added function to calculate Pseudotime (slignshot)
46+
* Included an easy-to-export differential frequency table
47+
* Added a function for random subsetting of the dataset
48+
* Added visualization of PC loadings
49+
* Added Pseudobulk PCA Analysis
50+
* Added function to easily export cellular frequency
51+
* Added function to change the parameter names (of the fcs files)
52+
* Added function to visualize DRs as density plot
53+
* Added Violin plot visualization of marker expression
54+
* Included option to not cluster rows and columns in heatmaps
55+
* Included option to show cluster numbers in the dotplot
56+
* Add multicore support to tSNE
57+
* Added workflow for UMAP projection and label transfer
58+
59+
# cyCONDOR 0.1.1
60+
61+
## Reference name: condor 0.1.1
62+
63+
* Add function to merge condor objects
64+
* Updated LoadFCS function to be fully compatible with .csv files
65+
* Updated UMAP function to run on multiple cores
66+
* Updated RPhenograph function to run on multiple cores
67+
* Added function to run FlowSOM clustering
68+
* Fix issues with UMAP parametes selections
69+
* Added option to specifiy the delimiter for the csv files
70+
71+
# cyCONDOR 0.1.0
72+
73+
## Reference name: condor 0.1.0
74+
75+
* Initial release

R/astir.R

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
#' runAstir_celltype
2+
#'
3+
#' @title runAstir_celltype
4+
#' @description Predict cell types using Astir. This package requires the python library `astir` and `reticulate` to work.
5+
#' @param fcd Flow cytometry dataset.
6+
#' @param data_slot Data slot to use for the analysis (e.g. "orig" or "norm").
7+
#' @param analysis_path Full path to the output folder of astir analysis.
8+
#' @param manifest_name Filename of the manifest file, this file must be located in the `analysis_path` folder.
9+
#' @param max_epochs Maximum number of epochs.
10+
#' @param learning_rate Learning Rate.
11+
#' @param initial_epochs Initial Epochs.
12+
#' @import reticulate
13+
#' @return runAstir_celltype
14+
#'
15+
#' @export
16+
runAstir_celltype <- function(fcd,
17+
data_slot,
18+
analysis_path,
19+
manifest_name,
20+
max_epochs,
21+
learning_rate,
22+
initial_epochs) {
23+
24+
# Save the expression matrix as csv
25+
write.csv(x = fcd$expr[[data_slot]], file = paste0(analysis_path, "expr.csv"))
26+
27+
# Import the astir python package
28+
ast_fun <- reticulate::import("astir")
29+
30+
# Set the directories for the analysis
31+
expr_path <- paste0(analysis_path, "expr.csv")
32+
33+
manifest_path <- paste0(analysis_path, manifest_name)
34+
35+
ast <- ast_fun$from_csv_yaml(csv_input = expr_path, marker_yaml = manifest_path)
36+
37+
batch_size = dim(ast$get_type_dataset()$get_exprs_df())[1]/100
38+
39+
ast$fit_type(max_epochs = as.integer(max_epochs),
40+
batch_size = as.integer(batch_size),
41+
learning_rate = learning_rate,
42+
n_init_epochs = as.integer(initial_epochs))
43+
44+
print(table(ast$get_celltypes()))
45+
46+
probabilities <- ast$get_celltype_probabilities()
47+
48+
diagnostic <- ast$diagnostics_celltype()
49+
50+
cell_types <- ast$get_celltypes()
51+
52+
write.csv(x = probabilities, file = paste0(analysis_path, "probabilities.csv"))
53+
54+
write.csv(x = diagnostic, file = paste0(analysis_path, "diagnostic.csv"))
55+
56+
write.csv(x = cell_types, file = paste0(analysis_path, "cell_types.csv"))
57+
58+
# Add the cell type prediction in the condor object
59+
60+
# Prepare the dataframe
61+
df <- data.frame(cell_type = cell_types,
62+
Description = paste0("Astir_cell_type_", data_slot,
63+
"_Max_Epoc_", max_epochs,
64+
"Learning_Rate_", learning_rate,
65+
"_Initial_Epochs_", initial_epochs))
66+
67+
fcd[["astir"]][[paste0("Astir_cell_type_", data_slot)]] <- df
68+
69+
return(fcd)
70+
71+
}
72+
73+
#' runAstir_cellstates
74+
#'
75+
#' @title runAstir_cellstates
76+
#' @description Predict cell states using Astir. This package requires the python library `astir` and `reticulate` to work.
77+
#' @param fcd Flow cytometry dataset.
78+
#' @param data_slot Data slot to use for the analysis (e.g. "orig" or "norm").
79+
#' @param analysis_path Full path to the output folder of astir analysis.
80+
#' @param manifest_name Filename of the manifest file, this file must be located in the `analysis_path` folder.
81+
#' @param max_epochs Maximum number of epochs.
82+
#' @param learning_rate Learning Rate.
83+
#' @param initial_epochs Initial Epochs.
84+
#' @import reticulate
85+
#' @importFrom utils write.csv
86+
#' @return runAstir_cellstates
87+
#'
88+
#' @export
89+
runAstir_cellstates <- function(fcd,
90+
data_slot,
91+
analysis_path,
92+
manifest_name,
93+
max_epochs,
94+
learning_rate,
95+
initial_epochs) {
96+
97+
# Save the expression matrix as csv
98+
write.csv(x = fcd$expr[[data_slot]], file = paste0(analysis_path, "expr.csv"))
99+
100+
# Import the astir python package
101+
ast_fun <- reticulate::import("astir")
102+
103+
# Set the directories for the analysis
104+
expr_path <- paste0(analysis_path, "expr.csv")
105+
106+
manifest_path <- paste0(analysis_path, manifest_name)
107+
108+
# Parpare to run astir
109+
ast <- ast_fun$from_csv_yaml(csv_input = expr_path, marker_yaml = manifest_path)
110+
111+
batch_size = dim(ast$get_type_dataset()$get_exprs_df())[1]/100
112+
113+
ast$fit_state(max_epochs = as.integer(max_epochs),
114+
batch_size = as.integer(batch_size),
115+
learning_rate = learning_rate,
116+
n_init_epochs = as.integer(initial_epochs))
117+
118+
diagnostic <- ast$diagnostics_cellstate()
119+
120+
cell_states <- ast$get_cellstates()
121+
122+
write.csv(x = diagnostic, file = paste0(analysis_path, "diagnostic.csv"))
123+
124+
write.csv(x = cell_states, file = paste0(analysis_path, "cell_states.csv"))
125+
126+
# Add the cell type prediction in the condor object
127+
128+
# Prepare the dataframe
129+
df <- data.frame(cell_states,
130+
Description = paste0("Astir_cell_state_", data_slot,
131+
"_Max_Epoc_", max_epochs,
132+
"Learning_Rate_", learning_rate,
133+
"_Initial_Epochs_", initial_epochs))
134+
135+
fcd[["astir"]][[paste0("Astir_cell_state_", data_slot)]] <- df
136+
137+
return(fcd)
138+
139+
}

0 commit comments

Comments
 (0)