spatialdata-io icon indicating copy to clipboard operation
spatialdata-io copied to clipboard

Handle Situation where V1 Visium `tissue_positions_list.csv` Has a Header

Open jeffquinn-msk opened this issue 1 year ago • 0 comments

I've been given a new dataset where the positions file is in the V1 location spatial/tissue_positions_list.csv, but it has a header. Really annoying I know. This ends up causing an exception in the Visium loader as the coordinates are loaded as string type by pandas. You might see similar data eventually as well I'm guessing..

Could we add something to the code to check for header in both locations? This is the function I wrote to deal with this:

def read_with_maybe_header(path, header):
    df = pd.read_csv(path)
    seen_header = df.columns
    if set(seen_header).issubset(set(header)):
        return df
    else:
        return pd.read_csv(path, names=header)

jeffquinn-msk avatar May 17 '24 14:05 jeffquinn-msk