parameters: (self)
docstring: Generates a pandas DataFrame with feature intensities from each sample in long format (over files).
  
          For labelled analyses channel intensities will be in one row, therefore resulting in a semi-long/block format.
          Resulting DataFrame can be joined with result from get_metadata_df by their index 'id'.
  
          Returns:
          pandas.DataFrame: intensity DataFrame
docstring_summary: Generates a pandas DataFrame with feature intensities from each sample in long format (over files).
docstring_tokens: Generates a pandas DataFrame with feature intensities from each sample in long format ( over files ) .
function: def get_intensity_df(self):
          """Generates a pandas DataFrame with feature intensities from each sample in long format (over files).
  
          For labelled analyses channel intensities will be in one row, therefore resulting in a semi-long/block format.
          Resulting DataFrame can be joined with result from get_metadata_df by their index 'id'.
  
          Returns:
          pandas.DataFrame: intensity DataFrame
          """
          labelfree = self.getExperimentType() == "label-free"
          filemeta = self.getColumnHeaders()  # type: dict[int, ColumnHeader]
  
          labels = list(set([header.label for header in filemeta.values()]))
          files = list(set([header.filename for header in filemeta.values()]))
          label_to_idx = {k: v for v, k in enumerate(labels)}
          file_to_idx = {k: v for v, k in enumerate(files)}
  
          def gen(cmap: ConsensusMap, fun):
              for f in cmap:
                  yield from fun(f)
  
          if not labelfree:
  
              def extract_row_blocks_channel_wide_file_long(f: ConsensusFeature):
                  subfeatures = f.getFeatureList()  # type: list[FeatureHandle]
                  filerows = defaultdict(lambda: [0] * len(labels))
                  for fh in subfeatures:
                      header = filemeta[fh.getMapIndex()]
                      row = filerows[header.filename]
                      row[label_to_idx[header.label]] = fh.getIntensity()
                  return (f.getUniqueId(), filerows)
  
              def extract_rows_channel_wide_file_long(f: ConsensusFeature):
                  uniqueid, rowdict = extract_row_blocks_channel_wide_file_long(f)
                  for file, row in rowdict.items():
                      row.append(file)
                      yield tuple([uniqueid] + row)
  
              if len(labels) == 1:
                  labels[0] = "intensity"
  
              dtypes = [('id', np.dtype('uint64'))] + list(zip(labels, ['f'] * len(labels)))
              dtypes.append(('file', 'U300'))
  
              intyarr = np.fromiter(iter=gen(self, extract_rows_channel_wide_file_long), dtype=dtypes, count=self.size())
  
              return pd.DataFrame(intyarr).set_index('id')
  
          else:
              # Specialized for LabelFree which has to have only one channel
              def extract_row_blocks_channel_long_file_wide_LF(f: ConsensusFeature):
                  subfeatures = f.getFeatureList()  # type: list[FeatureHandle]
                  row = [0.] * len(files)
  
                  for fh in subfeatures:
                      header = filemeta[fh.getMapIndex()]
                      row[file_to_idx[header.filename]] = fh.getIntensity()
  
                  yield tuple([f.getUniqueId()] + row)
  
              dtypes = [('id', np.dtype('uint64'))] + list(zip(files, ['f'] * len(files)))
  
              intyarr = np.fromiter(iter=gen(self, extract_row_blocks_channel_long_file_wide_LF), dtype=dtypes, count=self.size())
  
              return pd.DataFrame(intyarr).set_index('id')
function_tokens: def get_intensity_df ( self ) : labelfree = self . getExperimentType ( ) == "label-free" filemeta = self . getColumnHeaders ( ) # type: dict[int, ColumnHeader] labels = list ( set ( [ header . label for header in filemeta . values ( ) ] ) ) files = list ( set ( [ header . filename for header in filemeta . values ( ) ] ) ) label_to_idx = { k : v for v , k in enumerate ( labels ) } file_to_idx = { k : v for v , k in enumerate ( files ) } def gen ( cmap : ConsensusMap , fun ) : for f in cmap : yield from fun ( f ) if not labelfree : def extract_row_blocks_channel_wide_file_long ( f : ConsensusFeature ) : subfeatures = f . getFeatureList ( ) # type: list[FeatureHandle] filerows = defaultdict ( lambda : [ 0 ] * len ( labels ) ) for fh in subfeatures : header = filemeta [ fh . getMapIndex ( ) ] row = filerows [ header . filename ] row [ label_to_idx [ header . label ] ] = fh . getIntensity ( ) return ( f . getUniqueId ( ) , filerows ) def extract_rows_channel_wide_file_long ( f : ConsensusFeature ) : uniqueid , rowdict = extract_row_blocks_channel_wide_file_long ( f ) for file , row in rowdict . items ( ) : row . append ( file ) yield tuple ( [ uniqueid ] + row ) if len ( labels ) == 1 : labels [ 0 ] = "intensity" dtypes = [ ( 'id' , np . dtype ( 'uint64' ) ) ] + list ( zip ( labels , [ 'f' ] * len ( labels ) ) ) dtypes . append ( ( 'file' , 'U300' ) ) intyarr = np . fromiter ( iter = gen ( self , extract_rows_channel_wide_file_long ) , dtype = dtypes , count = self . size ( ) ) return pd . DataFrame ( intyarr ) . set_index ( 'id' ) else : # Specialized for LabelFree which has to have only one channel def extract_row_blocks_channel_long_file_wide_LF ( f : ConsensusFeature ) : subfeatures = f . getFeatureList ( ) # type: list[FeatureHandle] row = [ 0. ] * len ( files ) for fh in subfeatures : header = filemeta [ fh . getMapIndex ( ) ] row [ file_to_idx [ header . filename ] ] = fh . getIntensity ( ) yield tuple ( [ f . getUniqueId ( ) ] + row ) dtypes = [ ( 'id' , np . dtype ( 'uint64' ) ) ] + list ( zip ( files , [ 'f' ] * len ( files ) ) ) intyarr = np . fromiter ( iter = gen ( self , extract_row_blocks_channel_long_file_wide_LF ) , dtype = dtypes , count = self . size ( ) ) return pd . DataFrame ( intyarr ) . set_index ( 'id' )