Skip to content
Snippets Groups Projects
Commit 18bfacf0 authored by Paul Kühnel's avatar Paul Kühnel
Browse files

first version of a loom-file to pandas DataFrame method

parent 9e9437ab
No related branches found
No related tags found
1 merge request!1Dev
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
import loompy
import pandas as pd
def loom_to_pandas_df(file_name="testfiles/test.loom"):
"""
:param file_name: the name of the loom file (default is: "testfiles/test.loom")
:return: pandas DataFrame
"""
df = pd.DataFrame # Empty DataFrame - to return in case of wrong formatting
if file_name[-4:] != ".loom":
print(f"{file_name} is not a valid file name. Only use '.loom' files!")
with loompy.connect(file_name) as ds:
try:
df = pd.DataFrame(data=ds[:, :], index=ds.ra.Gene, columns=ds.ca.input_name)
except AttributeError or ValueError or OSError:
raise Exception(f"The loom file {file_name} does not exist or has no valid format!")
return df
https://github.com/slundberg/shap/issues/2909
Add the following to the lines causing the error
(replacing `@jit`):
@jit(nopython=True)
\ No newline at end of file
import loompy
import pandas as pd
ds = loompy.connect("test.loom")
df = pd.DataFrame(data=ds[:, :], index=ds.ra.Gene, columns=ds.ca.input_name)
ds.close()
df.info()
df.describe()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment