tcrdist3 icon indicating copy to clipboard operation
tcrdist3 copied to clipboard

KeyError: 'pmhc_a_aa'

Open Tianran1 opened this issue 2 years ago • 7 comments

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

Tianran1 avatar Oct 11 '22 07:10 Tianran1

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: @.***>

kmayerb avatar Oct 11 '22 16:10 kmayerb

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.

Tianran1 avatar Oct 11 '22 18:10 Tianran1

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: @.***>

kmayerb avatar Oct 11 '22 22:10 kmayerb

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

Tianran1 avatar Oct 12 '22 06:10 Tianran1

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 avatar Oct 12 '22 21:10 kmayerb

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 avatar Oct 12 '22 21:10 kmayerb

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: @.***>

kmayerb avatar Oct 12 '22 21:10 kmayerb