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

Stop mapping of query cells to child views if no cells are mapped in the parent view #4

Open
emdann opened this issue Nov 23, 2022 · 0 comments

Comments

@emdann
Copy link
Member

emdann commented Nov 23, 2022

Now it throws a big error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In [20], line 5
      3     organ_obs = adata_query.obs['organ'].copy()
      4     adata_query.obs.drop('organ', 1, inplace=True)
----> 5 mvatlas_mapped = mva.tl.add_query(mvatlas, adata_query)

File /nfs/team205/ed6/bin/multi-view-atlas/src/multi_view_atlas/tl/map_query.py:78, in add_query(mvatlas, adata_query)
     74     if depth > 0:
     75         adata_query_concat = adata_query_concat[
     76             new_view_assign.loc[adata_query_concat.obs_names, current_view] == 1
     77         ].copy()
---> 78     v_assign, next_view_adata = map_next_view(
     79         mvatlas, adata_query_concat, current_view=current_view, next_view=next_view
     80     )
     81     vdata_dict[next_view] = next_view_adata
     82 new_view_assign = pd.concat([new_view_assign, v_assign], 1)

File /nfs/team205/ed6/bin/multi-view-atlas/src/multi_view_atlas/tl/map_query.py:192, in map_next_view(mvatlas, adata_query, current_view, next_view, batch_key, batch_categories)
    189 # Get assignment to next view
    190 Y_assign_atlas = v_assign.loc[curr_view_adata.obs_names].values.ravel()
--> 192 v_assign_query = assign_from_similarity(Y_assign_atlas, X_similarity_atlas, X_similarity_query, v_assign)
    193 v_assign_query.index = adata_query.obs_names
    195 v_assign = pd.concat([v_assign, v_assign_query], axis=0)

File /nfs/team205/ed6/bin/multi-view-atlas/src/multi_view_atlas/tl/map_query.py:127, in assign_from_similarity(Y_assign_atlas, X_similarity_atlas, X_similarity_query, v_assign, k)
    124     raise ValueError("v_assign must have only one column")
    126 clf = KNeighborsClassifier(n_neighbors=k, metric="euclidean").fit(X_similarity_atlas, Y_assign_atlas)
--> 127 Y_assign_query = clf.predict(X_similarity_query)
    128 assign_predict = pd.DataFrame(Y_assign_query, columns=v_assign.columns)
    129 return assign_predict

File ~/my-conda-envs/patho-signatures-2/lib/python3.9/site-packages/sklearn/neighbors/_classification.py:226, in KNeighborsClassifier.predict(self, X)
    210 """Predict the class labels for the provided data.
    211 
    212 Parameters
   (...)
    221     Class labels for each data sample.
    222 """
    223 if self.weights == "uniform":
    224     # In that case, we do not need the distances to perform
    225     # the weighting so we do not compute them.
--> 226     neigh_ind = self.kneighbors(X, return_distance=False)
    227     neigh_dist = None
    228 else:

File ~/my-conda-envs/patho-signatures-2/lib/python3.9/site-packages/sklearn/neighbors/_base.py:745, in KNeighborsMixin.kneighbors(self, X, n_neighbors, return_distance)
    743         X = _check_precomputed(X)
    744     else:
--> 745         X = self._validate_data(X, accept_sparse="csr", reset=False, order="C")
    747 n_samples_fit = self.n_samples_fit_
    748 if n_neighbors > n_samples_fit:

File ~/my-conda-envs/patho-signatures-2/lib/python3.9/site-packages/sklearn/base.py:577, in BaseEstimator._validate_data(self, X, y, reset, validate_separately, **check_params)
    575     raise ValueError("Validation should be done on X, y or both.")
    576 elif not no_val_X and no_val_y:
--> 577     X = check_array(X, input_name="X", **check_params)
    578     out = X
    579 elif no_val_X and not no_val_y:

File ~/my-conda-envs/patho-signatures-2/lib/python3.9/site-packages/sklearn/utils/validation.py:909, in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator, input_name)
    907     n_samples = _num_samples(array)
    908     if n_samples < ensure_min_samples:
--> 909         raise ValueError(
    910             "Found array with %d sample(s) (shape=%s) while a"
    911             " minimum of %d is required%s."
    912             % (n_samples, array.shape, ensure_min_samples, context)
    913         )
    915 if ensure_min_features > 0 and array.ndim == 2:
    916     n_features = array.shape[1]

ValueError: Found array with 0 sample(s) (shape=(0, 1)) while a minimum of 1 is required by KNeighborsClassifier.
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

1 participant