mhorlbeck / ScreenProcessing

58 stars 31 forks source link

Error with loadData for screen_analysis.py #14

Closed a-brazel closed 1 year ago

a-brazel commented 3 years ago

Hi,

When using iPython in Mac terminal and trying to load data for screen_processing.py script I keep getting an error which prevents data loading. I have tried to load my own data and also the demo data (see below) without success.

Any idea how to fix this?

Thanks

In [5]: run screen_analysis.py
In [6]: data = loadData('Demo/Step3/ctx_demo_full')
~/.local/lib/python3.8/site-packages/pandas/io/parsers.py in __init__(self, kwds)
   1342             # GH 16338
   1343             elif not is_integer(self.header):
-> 1344                 raise ValueError("header must be integer or list of integers")
   1345             # GH 27779
   1346             elif self.header < 0:

ValueError: header must be integer or list of integers
sfederman commented 3 years ago

The below adjusted code seems to allow loadData to function properly:

def loadData(experimentName, collapsedToTranscripts = True, premergedCounts = False):
    dataDict = {'library': pd.read_csv(experimentName + '_librarytable.txt',sep='\t',header=0,index_col=0),
    'counts': pd.read_csv(experimentName + '_mergedcountstable.txt',sep='\t',header=[0,1],index_col=0),
    'phenotypes': pd.read_csv(experimentName + '_phenotypetable.txt',sep='\t',header=[0,1],index_col=0)}

    if premergedCounts:
        dataDict['premerged counts'] = pd.read_csv(experimentName + '_rawcountstable.txt',sep='\t',header=[0,1,2],index_col=0)

    if collapsedToTranscripts:
        dataDict['transcript scores'] = pd.read_csv(experimentName + '_genetable.txt',sep='\t',header=[0,1,2],index_col=[0,1])
        dataDict['gene scores'] = pd.read_csv(experimentName + '_genetable_collapsed.txt',sep='\t',header=[0,1,2],index_col=0)
    else:
        dataDict['gene scores'] = pd.read_csv(experimentName + '_genetable.txt',sep='\t',header=[0,1,2],index_col=0)

    return dataDict