Ejemplo n.º 1
0
    def apply(self, experiment = None):
        
        if not self.tubes or len(self.tubes) == 0:
            raise CytoflowOpError("Must specify some tubes!")
        
        # make sure each tube has the same conditions
        tube0_conditions = set(self.tubes[0].conditions)
        for tube in self.tubes:
            tube_conditions = set(tube.conditions)
            if len(tube0_conditions ^ tube_conditions) > 0:
                raise CytoflowOpError("Tube {0} didn't have the same "
                                      "conditions as tube {1}"
                                      .format(tube.file, self.tubes[0].file))

        # make sure experimental conditions are unique
        for idx, i in enumerate(self.tubes[0:-1]):
            for j in self.tubes[idx+1:]:
                if i.conditions_equal(j):
                    raise CytoflowOpError("The same conditions specified for "
                                          "tube {0} and tube {1}"
                                          .format(i.file, j.file))
        
        experiment = Experiment()
            
        for condition, dtype in self.conditions.items():
            is_log = False
            if dtype == "log":
                is_log = True
                dtype = "float"
            experiment.add_conditions({condition : dtype})
            if is_log:
                experiment.metadata[condition]["repr"] = "log"
        
        for tube in self.tubes:
            tube_fc = fcsparser.parse(tube.file, reformat_meta = True)
            if self.coarse:
                tube_meta, tube_data = tube_fc
                tube_data = tube_data.loc[np.random.choice(tube_data.index,
                                                           self.coarse_events,
                                                           replace = False)]
                tube_fc = (tube_meta, tube_data)
            experiment.add_tube(tube_fc, tube.conditions, ignore_v = self.ignore_v)
            
        return experiment
Ejemplo n.º 2
0
        self.value = new            

class SubsetEditor(BasicEditorFactory):
    
    # the editor to be created
    klass = _SubsetEditor
    
    # the name of the trait containing the cytoflow.Experiment to build the UI
    experiment = Str
    
    
if __name__ == '__main__':
     
    import fcsparser
     
    ex = Experiment()
    ex.add_conditions({"Dox" : "bool"})
     
    tube1 = fcsparser.parse('../cytoflow/tests/data/Plate01/RFP_Well_A3.fcs',
                            reformat_meta = True,
                            channel_naming = "$PnN")
 
    tube2 = fcsparser.parse('../cytoflow/tests/data/Plate01/CFP_Well_A4.fcs',
                            reformat_meta = True,
                            channel_naming = "$PnN")
     
    ex.add_tube(tube1, {"Dox" : True})
    ex.add_tube(tube2, {"Dox" : False})
     
    class C(HasTraits):
        val = Str()
Ejemplo n.º 3
0

class SubsetEditor(BasicEditorFactory):

    # the editor to be created
    klass = _SubsetEditor

    # the name of the trait containing the cytoflow.Experiment to build the UI
    experiment = Str


if __name__ == '__main__':

    import fcsparser

    ex = Experiment()
    ex.add_conditions({"Dox": "bool"})

    tube1 = fcsparser.parse('../cytoflow/tests/data/Plate01/RFP_Well_A3.fcs',
                            reformat_meta=True,
                            channel_naming="$PnN")

    tube2 = fcsparser.parse('../cytoflow/tests/data/Plate01/CFP_Well_A4.fcs',
                            reformat_meta=True,
                            channel_naming="$PnN")

    ex.add_tube(tube1, {"Dox": True})
    ex.add_tube(tube2, {"Dox": False})

    class C(HasTraits):
        val = Str()