Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read.gatingML.cytobank fails on biaxial gates drawn on compensated/uncompensated axes #49

Closed
bjreisman opened this issue Feb 23, 2019 · 4 comments

Comments

@bjreisman
Copy link

Thanks for your work on this package! I've run into the following issue: the read.gatingML.cytobank appears to fail when I attempt to read in an exported cytobank gatingML file with the following error message: (I'd be happy to share the gatingML file, but I'm not sure how to add attachments to github).

library(flowUtils)
library(CytoML)

file <-  "CytExp_29783_Gates_v5.xml"
gatingML.cytobank <- read.gatingML.cytobank(file)

Error in addGate(gateInfo, flowEnv, g, thisPopId, gateID) :
multiple gates found for Gate_1590224_dmlhYmxl

This gate corresponds to a polygon gate drawn against FSC and Ax700.
On inspecting the gatingML file, there appears to be only one Gate_1590224_dmlhYmxl defined.

<gating:PolygonGate gating:id="Gate_1590224_dmlhYmxl">
    <data-type:custom_info>
      <cytobank>
        <name>viable</name>
        <id>1590224</id>
        <gate_id>4</gate_id>
        <type>PolygonGate</type>
        <version>5</version>
        <compensation_id>3519</compensation_id>
        <fcs_file_id />
        <tailored>false</tailored>
        <tailored_per_population>false</tailored_per_population>
        <tailored_per_population_gateset_id />
        <fcs_file_filename />
        <definition>{"scale":{"x":{"flag":1,"argument":"1","min":1.0,"max":262144.0,"bins":256,"size":256},"y":{"flag":4,"argument":"1500","min":-4000.0,"max":262144.0,"bins":256,"size":256}},"positive":false,"negative":false,"label":[171153.05752893395,1.6602280372211227],"polygon":{"vertices":[[140789.0034748799,1.1618252220891794],[32490.54401542045,1.1618252220891794],[7187.1656370420715,0.48751553102831524],[17308.51698839342,-1.4181422915349964],[44636.165637042075,-1.8579094813572992],[179250.13861001504,-1.3888244788801762],[200504.9764478529,0.04774834120601246],[171153.05752893395,1.3670499106729208]]}}</definition>
      </cytobank>
    </data-type:custom_info>
    <gating:dimension gating:compensation-ref="uncompensated">
      <data-type:fcs-dimension data-type:name="FSC-A" />
    </gating:dimension>
    <gating:dimension gating:compensation-ref="Spill_3519" gating:transformation-ref="Tr_Arcsinh_1500"> 
      <data-type:fcs-dimension data-type:name="Comp_Alexa Fluor 700-A" />
    </gating:dimension>
    <gating:vertex>
      <gating:coordinate data-type:value="140789.0034748799" />
      <gating:coordinate data-type:value="1.1618252220891794" />
    </gating:vertex>
    <gating:vertex>
      <gating:coordinate data-type:value="32490.54401542045" />
      <gating:coordinate data-type:value="1.1618252220891794" />
    </gating:vertex>
    <gating:vertex>
      <gating:coordinate data-type:value="7187.1656370420715" />
      <gating:coordinate data-type:value="0.48751553102831524" />
    </gating:vertex>
    <gating:vertex>
      <gating:coordinate data-type:value="17308.51698839342" />
      <gating:coordinate data-type:value="-1.4181422915349964" />
    </gating:vertex>
    <gating:vertex>
      <gating:coordinate data-type:value="44636.165637042075" />
      <gating:coordinate data-type:value="-1.8579094813572992" />
    </gating:vertex>
    <gating:vertex>
      <gating:coordinate data-type:value="179250.13861001504" />
      <gating:coordinate data-type:value="-1.3888244788801762" />
    </gating:vertex>
    <gating:vertex>
      <gating:coordinate data-type:value="200504.9764478529" />
      <gating:coordinate data-type:value="0.04774834120601246" />
    </gating:vertex>
    <gating:vertex>
      <gating:coordinate data-type:value="171153.05752893395" />
      <gating:coordinate data-type:value="1.3670499106729208" />
    </gating:vertex>
  </gating:PolygonGate>

The flowUtils::read.gatingML function is able to read the gatingML file, and also only finds a single version of the gate in question:

flowEnv <- new.env()
gatingML <- read.gatingML(file, flowEnv)
table(grep("Gate_", names(flowEnv), value = T))
> table(grep("Gate_", names(flowEnv), value = T))
                Gate_1590221_aW50YWN0         Gate_1590222_c2luZ2xlcy1zc2M.         Gate_1590223_c2luZ2xlcy1mc2M.                 Gate_1590224_dmlhYmxl 
                                    1                                     1                                     1                                     1 
            Gate_1590225_YmFyY29kZWQ.                 Gate_1590226_cEJBQkU. Gate_1590227_cEJBQkUtSFJhc0cxMlYrSUwz Gate_1590228_cEJBQkUtSFJhc0cxMlYtSUwz 
                                    1                                     1                                     1                                     1 
Gate_1590229_cE1TQ1YtRUdGUl9MODU4Ug.. 
                                    1 

In my attempt to debug it, I believe the duplication is occurring within the parse.gateInfo() function: as can be seen here:

Browse[2]> gateInfo[,1:7]
                                       id               name gate_id fcs      comp_ref       trans_ref                                                 params
 1:                 Gate_1590221_aW50YWN0             intact       1     uncompensated                                                            SSC-A:FSC-A
 2:         Gate_1590222_c2luZ2xlcy1zc2M.        singles-ssc       2     uncompensated                                                            SSC-H:SSC-W
 3:         Gate_1590223_c2luZ2xlcy1mc2M.        singles-fsc       3     uncompensated                                                            FSC-W:FSC-H
 4:                 Gate_1590224_dmlhYmxl             viable       4     uncompensated Tr_Arcsinh_1500                           FSC-A:Comp_Alexa Fluor 700-A
 5:                 Gate_1590224_dmlhYmxl             viable       4        Spill_3519 Tr_Arcsinh_1500                           FSC-A:Comp_Alexa Fluor 700-A

It appears that the issue is that one of the gating axis is compensated (Ax700) while the other one is not (FSC-A), which the function interprets at there being two versions of the gate drawn on different compensation matrices.

@mikejiang
Copy link
Member

You can zip and attach the xml

@bjreisman
Copy link
Author

Thanks! See attached.
exampleGatingML.zip

@mikejiang
Copy link
Member

@bjreisman , let me know if it resolves your issue.

@bjreisman
Copy link
Author

The newest version worked! Thanks for the quick turnaround.

mikejiang pushed a commit that referenced this issue Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants