From 8a4f33bd341e6086291a8d99704693ee29961667 Mon Sep 17 00:00:00 2001 From: Jacob Wagner Date: Thu, 10 Sep 2020 18:35:55 -0700 Subject: [PATCH 1/6] Make load_cytoframe_from_fcs prefer flowCore_PnRmax like read.FCS --- src/MemCytoFrame.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/MemCytoFrame.cpp b/src/MemCytoFrame.cpp index 507747e..d6ca4f5 100644 --- a/src/MemCytoFrame.cpp +++ b/src/MemCytoFrame.cpp @@ -926,12 +926,12 @@ namespace cytolib for(int i = 1; i <= nrpar; i++) { string pid = to_string(i); - string range_str; - if( keys_.find("transformation")!=keys_.end() && keys_["transformation"] == "custom") - range_str = "flowCore_$P" + pid + "Rmax"; - else - range_str = "$P" + pid + "R"; + string range_str = "flowCore_$P" + pid + "Rmax"; it = keys_.find(range_str); + if( it==keys_.end() ){ + range_str = "$P" + pid + "R"; + it = keys_.find(range_str); + } if(it==keys_.end()) throw(domain_error(range_str + " not contained in Text section!")); else From d3f50ee1299b4e346d532cbb64dab107efbbc3d8 Mon Sep 17 00:00:00 2001 From: Jacob Wagner Date: Thu, 17 Sep 2020 11:29:40 -0700 Subject: [PATCH 2/6] Sync FCS parser handling of flowCore_PnRmax values match flowCore::read.FCS --- src/MemCytoFrame.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/MemCytoFrame.cpp b/src/MemCytoFrame.cpp index d6ca4f5..5b0dc06 100644 --- a/src/MemCytoFrame.cpp +++ b/src/MemCytoFrame.cpp @@ -928,15 +928,16 @@ namespace cytolib string pid = to_string(i); string range_str = "flowCore_$P" + pid + "Rmax"; it = keys_.find(range_str); - if( it==keys_.end() ){ + if( !(it == keys_.end())){ + params[i-1].max = boost::lexical_cast(it->second) + 1; + }else{ range_str = "$P" + pid + "R"; it = keys_.find(range_str); + if(it==keys_.end()) + throw(domain_error(range_str + " not contained in Text section!")); + else + params[i-1].max = boost::lexical_cast(it->second); } - if(it==keys_.end()) - throw(domain_error(range_str + " not contained in Text section!")); - else - params[i-1].max = boost::lexical_cast(it->second); - params[i-1].PnB = stoi(keys_["$P" + pid + "B"]); From 29a380e778c2ba15170e4ea503506f65966cd7b5 Mon Sep 17 00:00:00 2001 From: Jacob Wagner Date: Thu, 17 Sep 2020 15:42:29 -0700 Subject: [PATCH 3/6] Revert "Sync FCS parser handling of flowCore_PnRmax values match flowCore::read.FCS" This reverts commit d3f50ee1299b4e346d532cbb64dab107efbbc3d8. --- src/MemCytoFrame.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/MemCytoFrame.cpp b/src/MemCytoFrame.cpp index 5b0dc06..d6ca4f5 100644 --- a/src/MemCytoFrame.cpp +++ b/src/MemCytoFrame.cpp @@ -928,16 +928,15 @@ namespace cytolib string pid = to_string(i); string range_str = "flowCore_$P" + pid + "Rmax"; it = keys_.find(range_str); - if( !(it == keys_.end())){ - params[i-1].max = boost::lexical_cast(it->second) + 1; - }else{ + if( it==keys_.end() ){ range_str = "$P" + pid + "R"; it = keys_.find(range_str); - if(it==keys_.end()) - throw(domain_error(range_str + " not contained in Text section!")); - else - params[i-1].max = boost::lexical_cast(it->second); } + if(it==keys_.end()) + throw(domain_error(range_str + " not contained in Text section!")); + else + params[i-1].max = boost::lexical_cast(it->second); + params[i-1].PnB = stoi(keys_["$P" + pid + "B"]); From 17139e7c98fe2a97908972150b5aaf2b1400cd0c Mon Sep 17 00:00:00 2001 From: Jacob Wagner Date: Thu, 17 Sep 2020 15:42:58 -0700 Subject: [PATCH 4/6] Revert "Make load_cytoframe_from_fcs prefer flowCore_PnRmax like read.FCS" This reverts commit 8a4f33bd341e6086291a8d99704693ee29961667. --- src/MemCytoFrame.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/MemCytoFrame.cpp b/src/MemCytoFrame.cpp index d6ca4f5..507747e 100644 --- a/src/MemCytoFrame.cpp +++ b/src/MemCytoFrame.cpp @@ -926,12 +926,12 @@ namespace cytolib for(int i = 1; i <= nrpar; i++) { string pid = to_string(i); - string range_str = "flowCore_$P" + pid + "Rmax"; - it = keys_.find(range_str); - if( it==keys_.end() ){ + string range_str; + if( keys_.find("transformation")!=keys_.end() && keys_["transformation"] == "custom") + range_str = "flowCore_$P" + pid + "Rmax"; + else range_str = "$P" + pid + "R"; - it = keys_.find(range_str); - } + it = keys_.find(range_str); if(it==keys_.end()) throw(domain_error(range_str + " not contained in Text section!")); else From 42952b5a14233c2ce24b09ead299afe88e5361ad Mon Sep 17 00:00:00 2001 From: Jacob Wagner Date: Mon, 21 Sep 2020 14:20:40 -0700 Subject: [PATCH 5/6] Add support for transforming cytoframes not attached to GatingHierarchies --- inst/include/cytolib/MemCytoFrame.hpp | 2 ++ src/GatingHierarchy.cpp | 2 +- src/MemCytoFrame.cpp | 42 +++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/inst/include/cytolib/MemCytoFrame.hpp b/inst/include/cytolib/MemCytoFrame.hpp index b1414d6..e61de40 100644 --- a/inst/include/cytolib/MemCytoFrame.hpp +++ b/inst/include/cytolib/MemCytoFrame.hpp @@ -10,6 +10,7 @@ #ifndef INST_INCLUDE_CYTOLIB_MEMCYTOFRAME_HPP_ #define INST_INCLUDE_CYTOLIB_MEMCYTOFRAME_HPP_ #include "CytoFrame.hpp" +#include "trans_group.hpp" #include "readFCSdata.hpp" namespace cytolib @@ -186,6 +187,7 @@ class MemCytoFrame: public CytoFrame{ void append_data_columns(const EVENT_DATA_VEC & new_cols); + void transform_data(const trans_local & trans); }; diff --git a/src/GatingHierarchy.cpp b/src/GatingHierarchy.cpp index 7f1a9e3..41a5f76 100644 --- a/src/GatingHierarchy.cpp +++ b/src/GatingHierarchy.cpp @@ -173,7 +173,7 @@ namespace cytolib curTrans->transforming(¶m_range.second, 1); } - + cytoframe.set_keyword("transformation", "custom"); cytoframe.set_range(curChannel, ColType::channel, param_range); } diff --git a/src/MemCytoFrame.cpp b/src/MemCytoFrame.cpp index 507747e..493ec4a 100644 --- a/src/MemCytoFrame.cpp +++ b/src/MemCytoFrame.cpp @@ -937,6 +937,9 @@ namespace cytolib else params[i-1].max = boost::lexical_cast(it->second); + if(range_str == "flowCore_$P" + pid + "Rmax") + params[i-1].max += 1; + params[i-1].PnB = stoi(keys_["$P" + pid + "B"]); @@ -1061,6 +1064,45 @@ namespace cytolib return data_.colptr(idx); } + void MemCytoFrame::transform_data(const trans_local & trans) { + if(g_loglevel>=GATING_HIERARCHY_LEVEL) + PRINT("start transforming cytoframe data \n"); + if(n_rows()==0) + throw(domain_error("data is not loaded yet!")); + + vector channels=get_channels(); + int nEvents = n_rows(); + /* + * transforming each marker + */ + for(vector::iterator it1=channels.begin();it1!=channels.end();it1++) + { + + string curChannel=*it1; + auto param_range = get_range(curChannel, ColType::channel, RangeType::instrument); + TransPtr curTrans=trans.getTran(curChannel); + + if(curTrans) + { + if(curTrans->gateOnly()) + continue; + + EVENT_DATA_TYPE * x = get_data_memptr(curChannel, ColType::channel); + if(g_loglevel>=GATING_HIERARCHY_LEVEL) + { + string type; + curTrans->getType(type); + PRINT("transforming "+curChannel+" with func:"+type+"\n"); + } + curTrans->transforming(x,nEvents); + curTrans->transforming(¶m_range.first, 1); + curTrans->transforming(¶m_range.second, 1); + } + + set_keyword("transformation", "custom"); + set_range(curChannel, ColType::channel, param_range); + } + } }; From f529384c52f9478ce0d07bb3342e714b4159b887 Mon Sep 17 00:00:00 2001 From: Jacob Wagner Date: Mon, 21 Sep 2020 16:26:12 -0700 Subject: [PATCH 6/6] bump --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index a9ab663..926e07e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: cytolib Type: Package Title: C++ infrastructure for representing and interacting with the gated cytometry data -Version: 2.1.18 +Version: 2.1.19 Date: 2017-08-07 Author: Mike Jiang Maintainer: Mike Jiang , Jake Wagner