You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to replicate the Population Frequency Statistics calculated by FlowJo using the Population proportions extracted by FlowWorkspace from XML but for some reason basic conversion to percentage from the proportion and rounding with significant figures does not match the output from the FlowJo table export.
To perform this manual export of the Population Frequency from FlowJo, I go to Table Editor and select Create Table. The presumably default Table that is exported contains the Population Frequency in a Percent, which is rounded to 3 significant figures (My FlowJo Decimal Precision is set to 2, and my Significant Figures is set to 3). Below is the table (the first column are sensitive sample ID's.
Using FlowWorkspace/OpenCyto I export the frequency table using the "freq" and "wide" and transpose it to match the format of the Table that is exported from FlowJo:
library(openCyto)
library(flowWorkspace)
library(CytoML)
#> Warning: package 'CytoML' was built under R version 3.6.3
library(dplyr)
#> #> Attaching package: 'dplyr'#> The following objects are masked from 'package:stats':#> #> filter, lag#> The following objects are masked from 'package:base':#> #> intersect, setdiff, setequal, union
library(tibble)
library(reprex)
# not used for example...# open workspace and convert to gs# wsp <- CytoML::open_flowjo_xml(path)# gs <- wsp %>% flowjo_to_gatingset(name = "All Samples")# freq_gs <- flowWorkspace::gs_pop_get_count_fast(gs, statistic = "freq", format = "wide")# transpose to get into table format thats similar to flowjo export# t <- freq_gs %>% t() %>% as.data.frame() %>% dplyr::select(-root)# match same fcs file name as FlowJo export# t <- t %>% tibble::rownames_to_column("V1")# saved table to csv# write.csv(t, "~/projects/opencyto/cyto_ex.csv", row.names = FALSE)
And then convert the proportion derived from FlowWorkspace/openCyto (which are really small decimals) to percent. Using the sigfig preference (3) in the freq.signif() function they are off by a significant amount, so I included another function freq.close() but the values seem to be off by 1/1000th or so:
Example files here (trimmed to look at only the values that are not matching, which happen to be fractions of a percent): manual_ex.csv cyto_ex.csv
library(dplyr)
#> #> Attaching package: 'dplyr'#> The following objects are masked from 'package:stats':#> #> filter, lag#> The following objects are masked from 'package:base':#> #> intersect, setdiff, setequal, unionman_ex<- read.csv("~/projects/opencyto/manual_ex.csv")
cyto_ex<- read.csv("~/projects/opencyto/cyto_ex.csv")
freq.signif<-function(x){signif(x*100, digits=3)}
freq.close<-function(x){signif(signif(x*100, digits=2), digits=3)}
# manual table export from flowjo that i want to matchman_ex#> ID STIM TIME CD4.param1 CD4.param2 CD4.param3 CD8.param3 CD8.param4#> 1 sub1 stim1 time1 0.350 0.460 0.28 0.21 1.46#> 2 sub1 stim2 time1 0.380 0.450 0.36 0.24 1.54#> 3 sub2 stim1 time1 0.160 0.260 0.45 0.17 2.23#> 4 sub2 stim2 time1 0.077 0.073 0.66 0.34 2.37# raw export from flowworkspacecyto_ex#> ID STIM TIME CD4.param1 CD4.param2 CD4.param3 CD8.param3 CD8.param4#> 1 sub1 stim1 time1 0.0034525865 0.0045836062 0.002797786 0.002065787 0.01461942#> 2 sub1 stim2 time1 0.0038029193 0.0044740227 0.003635143 0.002427531 0.01542196#> 3 sub2 stim1 time1 0.0015723645 0.0025729601 0.004502680 0.001694915 0.02227603#> 4 sub2 stim2 time1 0.0007735448 0.0007251982 0.006647650 0.003414634 0.02365854# attempt to replicate using flowjo sigfigs (=3)dplyr::mutate_if(cyto_ex, is.numeric, freq.signif)
#> ID STIM TIME CD4.param1 CD4.param2 CD4.param3 CD8.param3 CD8.param4#> 1 sub1 stim1 time1 0.3450 0.4580 0.280 0.207 1.46#> 2 sub1 stim2 time1 0.3800 0.4470 0.364 0.243 1.54#> 3 sub2 stim1 time1 0.1570 0.2570 0.450 0.169 2.23#> 4 sub2 stim2 time1 0.0774 0.0725 0.665 0.341 2.37# applying signif function thats close, CD8.param4 is off by 1/1000thdplyr::mutate_if(cyto_ex, is.numeric, freq.close)
#> ID STIM TIME CD4.param1 CD4.param2 CD4.param3 CD8.param3 CD8.param4#> 1 sub1 stim1 time1 0.350 0.460 0.28 0.21 1.5#> 2 sub1 stim2 time1 0.380 0.450 0.36 0.24 1.5#> 3 sub2 stim1 time1 0.160 0.260 0.45 0.17 2.2#> 4 sub2 stim2 time1 0.077 0.073 0.66 0.34 2.4
Is this an issue of including (or not including) the last values of these really small decimals? Or could it be an artifact stemming from the parsing of the wsp/XML counts?
Unfortunately my organization will not be updating to R4.0 for awhile so I apologize for not having the cleanest reprex. I want to believe that the inability to calculate the same exact values as FlowJo is not because of the version. You should be able to recreate this easily by exporting a Freq. Table from FlowJo and comparing it to the FlowWorkspace exported Freq. Table and converting the proportion to a percent.
FlowJo Version: 10.5.3
FlowJo Engine: v4.00770
OS: Windows 10
Java Version: 1.8.0_161-b12
Build Number 10.5.3
The text was updated successfully, but these errors were encountered:
miosisoniii
changed the title
gs_pop_get_stat_fast() freq extract not matching FlowJo Pop Freq Table Export
gs_pop_get_count_fast() freq extract not matching FlowJo Pop Freq Table Export
Feb 8, 2022
In my opinion, this amount of difference is expected, since flowWorkspace does its own gating independently from flowjo based on that gates parsed from XML, you can verified the difference of cell count
gh_pop_compare_stats(gs[[1]])
If you want to have the exact same stats from flowjo, simply ask for flowjo stats from this API that is
gs_pop_get_count_fast(gs, statistic = "freq", format = "wide",xml = TRUE)
I am trying to replicate the Population Frequency Statistics calculated by FlowJo using the Population proportions extracted by FlowWorkspace from XML but for some reason basic conversion to percentage from the proportion and rounding with significant figures does not match the output from the FlowJo table export.
To perform this manual export of the Population Frequency from FlowJo, I go to Table Editor and select Create Table. The presumably default Table that is exported contains the Population Frequency in a Percent, which is rounded to 3 significant figures (My FlowJo Decimal Precision is set to 2, and my Significant Figures is set to 3). Below is the table (the first column are sensitive sample ID's.
Using FlowWorkspace/OpenCyto I export the frequency table using the "freq" and "wide" and transpose it to match the format of the Table that is exported from FlowJo:
Created on 2022-02-04 by the reprex package (v2.0.1)
Session info
Created on 2022-02-04 by the reprex package (v2.0.1)
And then convert the proportion derived from FlowWorkspace/openCyto (which are really small decimals) to percent. Using the sigfig preference (3) in the freq.signif() function they are off by a significant amount, so I included another function freq.close() but the values seem to be off by 1/1000th or so:
Example files here (trimmed to look at only the values that are not matching, which happen to be fractions of a percent):
manual_ex.csv
cyto_ex.csv
Created on 2022-02-04 by the reprex package (v2.0.1)
Session info
After reaching out to FlowJo directly:
Is this an issue of including (or not including) the last values of these really small decimals? Or could it be an artifact stemming from the parsing of the wsp/XML counts?
Unfortunately my organization will not be updating to R4.0 for awhile so I apologize for not having the cleanest reprex. I want to believe that the inability to calculate the same exact values as FlowJo is not because of the version. You should be able to recreate this easily by exporting a Freq. Table from FlowJo and comparing it to the FlowWorkspace exported Freq. Table and converting the proportion to a percent.
FlowJo Version: 10.5.3
FlowJo Engine: v4.00770
OS: Windows 10
Java Version: 1.8.0_161-b12
Build Number 10.5.3
The text was updated successfully, but these errors were encountered: