kmayerb / tcrdist3

flexible CDR based distance metrics
MIT License
52 stars 16 forks source link

KeyError: 'pmhc_a_aa' #76

Open Tianran1 opened 1 year ago

Tianran1 commented 1 year ago

Hi, I am new to tcrdist. When I want to compute the distance between two sets using "compute_rect_distances", it always gives me the KeyError: 'pmhc_a_aa'. Does anyone know how to fix it? Thanks

kmayerb commented 1 year ago

can you provide the code you used to generate this error?

On Tue, Oct 11, 2022 at 12:30 AM Tianran1 @.***> wrote:

Hi, I am new to tcrdist. When I want to compute the distance between two sets using "compute_rect_distances", it always gives me the KeyError: 'pmhc_a_aa'. Does anyone know how to fix it? Thanks

— Reply to this email directly, view it on GitHub https://github.com/kmayerb/tcrdist3/issues/76, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALD2PVYC662UGTCOHTTRSMTWCUJRDANCNFSM6AAAAAARB7Q4UY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Tianran1 commented 1 year ago

Hi, I just used the example code from your pipeline.

""" import pandas as pd from tcrdist.repertoire import TCRrep

df = pd.read_csv("dash.csv") df2 = pd.read_csv("dash2.csv") df = df.head(10) #(1) tr = TCRrep(cell_df = df, #(2) df2 = df2, organism = 'mouse', chains = ['alpha','beta'], db_file = 'alphabeta_gammadelta_db.tsv')

assert tr.pw_alpha.shape == (10,10) assert tr.pw_beta.shape == (10,10)

tr.compute_rect_distances() # (3) assert tr.rw_alpha.shape == (10,1924) assert tr.rw_beta.shape == (10,1924)

df3 = df2.head(100)

tr.compute_rect_distances(df = tr.clone_df, df2 = df3) # (4) assert tr.rw_alpha.shape == (10,100) assert tr.rw_beta.shape == (10,100)

tr.compute_rect_distances( df = tr.clone_df.iloc[0:2,], # (5) df2 = df3)
assert tr.rw_alpha.shape == (2,100) assert tr.rw_beta.shape == (2,100) """

I only changed the df2 to be df as well because I cannot find the dash2.csv. Could you have a look? Many thanks.

kmayerb commented 1 year ago

TCRrep has no argument df2.

what you want is something like this:

"""

df = pd.read_csv("dash.csv").head(10) df2 = pd.read_csv("dash.csv")

tr = TCRrep(cell_df = df, organism = 'mouse', chains = ['alpha','beta'], compute_distances = False)

tr2 = TCRrep(cell_df = df2, organism = 'mouse', chains = ['alpha','beta'], compute_distances = False)

tr.compute_rect_distances( df = tr.clone_df, df2 = tr2.clone_df)

"""

Does this help?

On Tue, Oct 11, 2022 at 11:16 AM Tianran1 @.***> wrote:

Hi, I just used the example code from your pipeline.

""" import pandas as pd from tcrdist.repertoire import TCRrep

df = pd.read_csv("dash.csv") df2 = pd.read_csv("dash2.csv") df = df.head(10) #(1) tr = TCRrep(cell_df = df, #(2) df2 = df2, organism = 'mouse', chains = ['alpha','beta'], db_file = 'alphabeta_gammadelta_db.tsv')

assert tr.pw_alpha.shape == (10,10) assert tr.pw_beta.shape == (10,10)

tr.compute_rect_distances() # (3) assert tr.rw_alpha.shape == (10,1924) assert tr.rw_beta.shape == (10,1924)

df3 = df2.head(100)

tr.compute_rect_distances(df = tr.clone_df, df2 = df3) # (4) assert tr.rw_alpha.shape == (10,100) assert tr.rw_beta.shape == (10,100)

tr.compute_rect_distances( df = tr.clone_df.iloc[0:2,], # (5) df2 = df3) assert tr.rw_alpha.shape == (2,100) assert tr.rw_beta.shape == (2,100) """

I only changed the df2 to be df as well because I cannot find the dash2.csv. Could you have a look? Many thanks.

— Reply to this email directly, view it on GitHub https://github.com/kmayerb/tcrdist3/issues/76#issuecomment-1275093153, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALD2PV7XRSOZIBOLYIRG3HTWCWVGDANCNFSM6AAAAAARB7Q4UY . You are receiving this because you commented.Message ID: @.***>

Tianran1 commented 1 year ago

Hi, thanks very much. Now it works. Then maybe you need to change the pipeline example since it's not correct.

kmayerb commented 1 year ago

thanks can you send me the link to the example you were initially using.

On Tue, Oct 11, 2022 at 11:56 PM Tianran1 @.***> wrote:

Hi, thanks very much. Now it works. Then maybe you need to change the pipeline example since it's not correct.

— Reply to this email directly, view it on GitHub https://github.com/kmayerb/tcrdist3/issues/76#issuecomment-1275681351, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALD2PV453RWV2Z3TYZHH22DWCZOK3ANCNFSM6AAAAAARB7Q4UY . You are receiving this because you commented.Message ID: @.***>

kmayerb commented 1 year ago

will change this: https://tcrdist3.readthedocs.io/en/latest/tcrdistances.html#i-want-distances-from-1-tcr-to-many-tcrs

On Wed, Oct 12, 2022 at 2:09 PM tcrdist 3 @.***> wrote:

thanks can you send me the link to the example you were initially using.

On Tue, Oct 11, 2022 at 11:56 PM Tianran1 @.***> wrote:

Hi, thanks very much. Now it works. Then maybe you need to change the pipeline example since it's not correct.

— Reply to this email directly, view it on GitHub https://github.com/kmayerb/tcrdist3/issues/76#issuecomment-1275681351, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALD2PV453RWV2Z3TYZHH22DWCZOK3ANCNFSM6AAAAAARB7Q4UY . You are receiving this because you commented.Message ID: @.***>

kmayerb commented 1 year ago

I think the test works because dash2.csv already has precomputed the other CDR columns, I agree this is a confusing example. Thanks for bringing it to my attention.

https://github.com/kmayerb/tcrdist3/blob/master/dash2.csv

On Wed, Oct 12, 2022 at 2:11 PM tcrdist 3 @.***> wrote:

will change this:

https://tcrdist3.readthedocs.io/en/latest/tcrdistances.html#i-want-distances-from-1-tcr-to-many-tcrs

On Wed, Oct 12, 2022 at 2:09 PM tcrdist 3 @.***> wrote:

thanks can you send me the link to the example you were initially using.

On Tue, Oct 11, 2022 at 11:56 PM Tianran1 @.***> wrote:

Hi, thanks very much. Now it works. Then maybe you need to change the pipeline example since it's not correct.

— Reply to this email directly, view it on GitHub https://github.com/kmayerb/tcrdist3/issues/76#issuecomment-1275681351, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALD2PV453RWV2Z3TYZHH22DWCZOK3ANCNFSM6AAAAAARB7Q4UY . You are receiving this because you commented.Message ID: @.***>