jiangdada1221 / tcrpeg Goto Github PK
View Code? Open in Web Editor NEWDeep autoregressive generative models capture the intrinsics embedded in t-cell receptor repertoires
License: GNU General Public License v3.0
Deep autoregressive generative models capture the intrinsics embedded in t-cell receptor repertoires
License: GNU General Public License v3.0
Hi,
I tried to used TCRpeg with your pre-trained model but when I did the classification task I've got the following error:
auc,aup,y_pres,y_trues = tcrpeg_c.evaluate(x_test=x_test,y_test=y_test,batch_size=10)
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[49], line 1
----> 1 auc,aup,y_pres,y_trues = tcrpeg_c.evaluate(x_test=x_test,y_test=y_test,batch_size=10)
File ~\TCR_peg\TCRpeg-main\TCRpeg-main\tcrpeg\classification.py:241, in classification.evaluate(self, x_test, y_test, batch_size, record_path)
239 y_batch = torch.FloatTensor(y_batch).to(self.device)
240 batch_size_temp = len(x_batch)
--> 241 x_batch = self.emb_model.get_embedding(x_batch,last_layer = self.last_layer)
242 x_batch = torch.tensor(x_batch).to(self.device)
244 y_pres = self.model(x_batch).view(batch_size_temp)
File ~\TCR_peg\TCRpeg-main\TCRpeg-main\tcrpeg\TCRpeg.py:718, in TCRpeg.get_embedding(self, seqs, last_layer)
716 self.model.eval()
717 with torch.no_grad():
--> 718 inputs,targets,lengths = self.aas2embs(seqs)
719 inputs,targets,lengths = torch.LongTensor(inputs).to(self.device),torch.LongTensor(targets).to(self.device),torch.LongTensor(lengths).to(self.device)
720 if self.vj:
File ~\TCR_peg\TCRpeg-main\TCRpeg-main\tcrpeg\TCRpeg.py:138, in TCRpeg.aas2embs(self, seqs)
132 def aas2embs(self, seqs):
133 """
134 @seqs: list of AAs
135
136 #return [[1,2,3,0,0],[2,3,4,0].....], the padded
137 """
--> 138 seqs = [[self.aa2idx[k] + 1 for k in seq] for seq in seqs]
139 # lengths = [len(seq)+2 for seq in seqs] #contains start and stop
140 lengths = [len(seq) + 1 for seq in seqs] # contains the start token
File ~\TCR_peg\TCRpeg-main\TCRpeg-main\tcrpeg\TCRpeg.py:138, in <listcomp>(.0)
132 def aas2embs(self, seqs):
133 """
134 @seqs: list of AAs
135
136 #return [[1,2,3,0,0],[2,3,4,0].....], the padded
137 """
--> 138 seqs = [[self.aa2idx[k] + 1 for k in seq] for seq in seqs]
139 # lengths = [len(seq)+2 for seq in seqs] #contains start and stop
140 lengths = [len(seq) + 1 for seq in seqs] # contains the start token
File ~\TCR_peg\TCRpeg-main\TCRpeg-main\tcrpeg\TCRpeg.py:138, in <listcomp>(.0)
132 def aas2embs(self, seqs):
133 """
134 @seqs: list of AAs
135
136 #return [[1,2,3,0,0],[2,3,4,0].....], the padded
137 """
--> 138 seqs = [[self.aa2idx[k] + 1 for k in seq] for seq in seqs]
139 # lengths = [len(seq)+2 for seq in seqs] #contains start and stop
140 lengths = [len(seq) + 1 for seq in seqs] # contains the start token
KeyError: 'X'
My file is composed of two columns : seq and label columns as yours. When I used your file (classification.csv), I do not have the error, the command line works fine.
Can you highlight me on the origine of this error ?!
If needed, I can send you my data file.
Best
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.