KrishnaswamyLab / SAUCIE

Other
98 stars 29 forks source link

How should I "provide each point's batch as a label"? #29

Closed zhuy16 closed 4 years ago

zhuy16 commented 4 years ago

I am stacked at batch correction, please advise how to proceed here, appreciate!

My code:

x1 = np.concatenate([np.random.uniform(-3, -2, (1000, 40)), np.random.uniform(2, 3, (1000, 40))], axis=0) x2 = np.concatenate([np.random.uniform(-3, -2, (1000, 40)), np.random.uniform(2, 3, (1000, 40))], axis=0) x = np.concatenate([x1,x2],axis=0) load = SAUCIE.Loader(x, shuffle=False) saucie = SAUCIE.SAUCIE(x.shape[1], lambda_b=.1) labels=[0 for i in range(2000)]+[1 for i in range(2000)] saucie.batches=np.array(labels) saucie.train(load, 100)

Error:

Exception Traceback (most recent call last)

in ----> 1 saucie.train(load, 100) 2 embedding = saucie.get_embedding(load) 3 num_clusters, clusters = saucie.get_clusters(load) /hpcdata/bcbb/yunhua/F20/SAUCIE/model.py in train(self, load, steps, batch_size) 407 # if using batch-correction, must have labels 408 if (self.lambda_b and len(batch) < 2): --> 409 raise Exception("If using lambda_b (batch correction), you must provide each point's batch as a label") 410 411 ops = [obn('train_op')] Exception: If using lambda_b (batch correction), you must provide each point's batch as a label
mattamodio commented 4 years ago

The Loader object takes an optional second argument "labels", so you can pass in your labels as a numpy array when creating the loader like this: load = Loader(x, labels, shuffle=True) and give that object to saucie.train, which will automatically detect the labels.

Hope that helps!

zhuy16 commented 4 years ago

Great! Thanks!

From: Matt Amodio notifications@github.com Reply-To: KrishnaswamyLab/SAUCIE reply@reply.github.com Date: Monday, June 29, 2020 at 1:09 PM To: KrishnaswamyLab/SAUCIE SAUCIE@noreply.github.com Cc: "Zhu, Yunhua (NIH/NIAID) [C]" yunhua.zhu@nih.gov, Author author@noreply.github.com Subject: Re: [KrishnaswamyLab/SAUCIE] How should I "provide each point's batch as a label"? (#29)

Closed #29https://github.com/KrishnaswamyLab/SAUCIE/issues/29.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/KrishnaswamyLab/SAUCIE/issues/29#event-3493707357, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANC3VBGNCYEUUOODYIJIIP3RZDDENANCNFSM4OKJKJYA.