Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with pySCN.scn_classify: "Data matrix has wrong shape(), need to be (x,y)." #2

Open
kma2112 opened this issue Apr 23, 2021 · 1 comment

Comments

@kma2112
Copy link

kma2112 commented Apr 23, 2021

I've been using the same code that worked for me previously, but just started getting an error at the pySCN.scn_classify step and was wondering what I might be doing wrong or if there is an incompatibility with one of the package versions I am using. It throws an error when ad._core.views.ArrayView is called.

My code is below, as well as a screenshot of my error report and session info. Files are too large to be uploaded here but are in my Dropbox under Cahan lab: Kathleen.Noller/forgithub/ (https://www.dropbox.com/s/k5hrbbflh32w56x/forgithub.zip?dl=0)

adRaw = sc.read_loom("../data/LLi-21-FT/velocyto/LLi-21-FT.loom")
adRaw.obs_names_make_unique()
adRaw.var_names_make_unique()

from joblib import dump, load

tspRF = load("../101520/tspRF_FallopianTube_Ahmed_101520.joblib")
cgenesA = load("../101520/cgenesA_FallopianTube_Ahmed_101520.joblib")
xpairs = load("../101520/xpairs_FallopianTube_Ahmed_101520.joblib")

adClassRes = pySCN.scn_classify(adRaw, cgenesA, xpairs, tspRF, nrand = 0)

Screen Shot 2021-04-22 at 8 38 35 PM

Screen Shot 2021-04-22 at 8 38 43 PM

Thank you for your help!

@Yves33
Copy link

Yves33 commented May 10, 2021

Same issue here, with the files from tutorial (adLung_TabSen_100920.h5ad,...)
adVal = pySCN.scn_classify(expVal, cgenesA, xpairs, tspRF, nrand = 0)
(...)ValueError: Data matrix has wrong shape (), need to be (500, 16543).

(fedora 33/x86_64)

Edit:

solved by adding
if isinstance(aDat.X,np.ndarray):
in scn_train.py, line 98
final code should be

def scn_predict(cgenes, xpairs, rf_tsp, aDat, nrand = 2):
    # in the case of aDat.X is a numpy array
    if isinstance(aDat.X,np.ndarray):
        aDat.X = ad._core.views.ArrayView(aDat.X)
###    expDat= pd.DataFrame(data=aDat.X, index= aDat.obs.index.values, columns= aDat.var.index.values)
    expDat= pd.DataFrame(data=aDat.X.toarray(), index= aDat.obs.index.values, columns= aDat.var.index.values)
    expValTrans=query_transform(expDat.reindex(labels=cgenes, axis='columns', fill_value=0), xpairs)
    classRes_val=rf_classPredict(rf_tsp, expValTrans, numRand=nrand)
    return classRes_val

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants