alok-ai-lab / pyDeepInsight

A python implementation of the DeepInsight methodology.
GNU General Public License v3.0
157 stars 47 forks source link

ValueError: Need at least 2-D data #34

Closed sarah127 closed 5 months ago

sarah127 commented 1 year ago

after running this code : expr_file = r"./data/curatedTCGAData_RNASeq2GeneNorm-20160128.txt.gz" expr = pd.read_csv(expr_file, sep="\t") y = expr['cancer'].values X = expr.iloc[:, 2:].values X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=0.2, stratify=y)

var_filter = X_train.var(0) >= np.percentile(X_train.var(0), 30., method='nearest') mms = MinMaxScaler() X_train_norm = mms.fit_transform(X_train[:, var_filter]) X_test_norm = mms.transform(X_test[:, var_filter]) le = LabelEncoder() y_train_enc = le.fit_transform(y_train) y_test_enc = le.transform(y_test)

lemapping = dict(zip(le.transform(le.classes), le.classes_)) num_classes = np.unique(y_train_enc).size reducer = umap.UMAP( n_components=2,

min_dist=0.8,

metric='cosine',
n_jobs=-1

)

pixel_size = (224,224) it = ImageTransformer( feature_extractor=reducer, pixels=pixel_size) it.fit(X_train_norm, y=y_train, plot=True) X_train_img = it.transform(X_train_norm) X_test_img = it.transform(X_test_norm)

it reduces this error

ValueError Traceback (most recent call last) Cell In[27], line 22 18 pixel_size = (224,224) 19 it = ImageTransformer( 20 feature_extractor=reducer, 21 pixels=pixel_size) ---> 22 it.fit(X_train_norm, y=y_train, plot=True) 23 X_train_img = it.transform(X_train_norm) 24 X_test_img = it.transform(X_test_norm)

File /usr/local/lib/python3.8/site-packages/pyDeepInsight/transformer.py:116, in ImageTransformer.fit(self, X, y, plot) 114 self.x_rot_l = [] 115 for x_new in x_new_l: --> 116 chvertices = ConvexHull(x_new).vertices 117 hull_points = x_new[chvertices] 118 # determine the minimum bounding rectangle

File _qhull.pyx:2458, in scipy.spatial._qhull.ConvexHull.init()

File _qhull.pyx:278, in scipy.spatial._qhull._Qhull.init()

ValueError: Need at least 2-D data

thanks

kaboroevich commented 1 year ago

I tried the code on in a new environment and did not get the same error.

Can you give me the result of expr.shape and expr.head()?