getzlab / SignatureAnalyzer

Updated SignatureAnalyzer-GPU with mutational spectra & RNA expression compatibility.
MIT License
71 stars 21 forks source link

KeyError: 'Tumor_Sample_Barcode' #36

Closed ksingh1119 closed 2 years ago

ksingh1119 commented 2 years ago
Screen Shot 2021-11-08 at 10 59 57 PM

Hi,

I keep getting this key error although my MAF file has a column for the Tumor_Sample_Barcode, any suggestions on the fix. I've also attached a screenshot of the MAF file. Thanks for your help in advance!

shankara-a commented 2 years ago

Hi @ksingh1119 ,

The Tumor_Sample_Barcode should be unique sample/patient ID in your .maf. For the input to the algorithm, it generates spectra per patient - meaning we have (patients x 96 SBS spectra, for example). Thus, it uses the Tumor_Sample_Barcode to assign mutations to samples.

Does your .maf only have one sample? If so, you might not have enough samples to perform decomposition with ard-nmf. I might recommend a supervised approach.

Please let me know if you have any other questions!

Shankara

ksingh1119 commented 2 years ago

HI,

Thank you so much for your quick response. I am running only one sample at this time for testing purposes and I will try the supervised approach and see if that works. Thanks for your help again and will reach out if I have any issues.

Kind Regards, Kunwar

On Tue, Nov 9, 2021 at 5:20 AM Shankara Anand @.***> wrote:

Hi @ksingh1119 https://github.com/ksingh1119 ,

The Tumor_Sample_Barcode should be unique sample/patient ID in your .maf. For the input to the algorithm, it generates spectra per patient - meaning we have (patients x 96 SBS spectra, for example). Thus, it uses the Tumor_Sample_Barcode to assign mutations to samples.

Does your .maf only have one sample? If so, you might not have enough samples to perform decomposition with ard-nmf. I might recommend a supervised https://github.com/getzlab/getzlab-SignatureAnalyzer/blob/master/signatureanalyzer/Supervised_HowTo.ipynb approach.

Please let me know if you have any other questions!

Shankara

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/getzlab/getzlab-SignatureAnalyzer/issues/36#issuecomment-964144853, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLDQSWLRBJK3MMPOYJQ3ZTULENYPANCNFSM5HUQPLLA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

ksingh1119 commented 2 years ago

Apologies for the repeat question but I now running into the following issue running the supervised script in python :

AttributeError: module 'signatureanalyzer' has no attribute 'spectra'

Any suggested work around?

Thanks!

On Tue, Nov 9, 2021 at 11:08 AM Kunwar Singh @.***> wrote:

HI,

Thank you so much for your quick response. I am running only one sample at this time for testing purposes and I will try the supervised approach and see if that works. Thanks for your help again and will reach out if I have any issues.

Kind Regards, Kunwar

On Tue, Nov 9, 2021 at 5:20 AM Shankara Anand @.***> wrote:

Hi @ksingh1119 https://github.com/ksingh1119 ,

The Tumor_Sample_Barcode should be unique sample/patient ID in your .maf. For the input to the algorithm, it generates spectra per patient - meaning we have (patients x 96 SBS spectra, for example). Thus, it uses the Tumor_Sample_Barcode to assign mutations to samples.

Does your .maf only have one sample? If so, you might not have enough samples to perform decomposition with ard-nmf. I might recommend a supervised https://github.com/getzlab/getzlab-SignatureAnalyzer/blob/master/signatureanalyzer/Supervised_HowTo.ipynb approach.

Please let me know if you have any other questions!

Shankara

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/getzlab/getzlab-SignatureAnalyzer/issues/36#issuecomment-964144853, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLDQSWLRBJK3MMPOYJQ3ZTULENYPANCNFSM5HUQPLLA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

ksingh1119 commented 2 years ago

Sorry I resolved that error but I keep getting this reference error am I supposed to change the reference directory?

TypeError: get_spectra_from_maf() got an unexpected keyword argument 'reference'

On Tue, Nov 9, 2021 at 7:57 PM Kunwar Singh @.***> wrote:

Apologies for the repeat question but I now running into the following issue running the supervised script in python :

AttributeError: module 'signatureanalyzer' has no attribute 'spectra'

Any suggested work around?

Thanks!

On Tue, Nov 9, 2021 at 11:08 AM Kunwar Singh @.***> wrote:

HI,

Thank you so much for your quick response. I am running only one sample at this time for testing purposes and I will try the supervised approach and see if that works. Thanks for your help again and will reach out if I have any issues.

Kind Regards, Kunwar

On Tue, Nov 9, 2021 at 5:20 AM Shankara Anand @.***> wrote:

Hi @ksingh1119 https://github.com/ksingh1119 ,

The Tumor_Sample_Barcode should be unique sample/patient ID in your .maf. For the input to the algorithm, it generates spectra per patient - meaning we have (patients x 96 SBS spectra, for example). Thus, it uses the Tumor_Sample_Barcode to assign mutations to samples.

Does your .maf only have one sample? If so, you might not have enough samples to perform decomposition with ard-nmf. I might recommend a supervised https://github.com/getzlab/getzlab-SignatureAnalyzer/blob/master/signatureanalyzer/Supervised_HowTo.ipynb approach.

Please let me know if you have any other questions!

Shankara

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/getzlab/getzlab-SignatureAnalyzer/issues/36#issuecomment-964144853, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLDQSWLRBJK3MMPOYJQ3ZTULENYPANCNFSM5HUQPLLA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

shankara-a commented 2 years ago

Are you using the most up to date version? Maybe try installing the dev version with these instructions: https://github.com/getzlab/getzlab-SignatureAnalyzer#git-clone

The function call has thereference kwarg: https://github.com/getzlab/getzlab-SignatureAnalyzer/blob/94c8a98209c400095862b538b843d82ea47dd8b9/signatureanalyzer/spectra.py#L10

ksingh1119 commented 2 years ago

Hi,

I believe I was using the most updated version, I just cloned the dev version and tried to run the same supervised code in python and I am getting the original error message of tumor_sampel_barcode. Should I go back and install the pip3 version and are my pathways correct? Thanks for your help and appreciate you getting back to me so quickly. Have a wonderful day!

import pandas as pd

import signatureanalyzer as sa

REF= "/users/kunwarsingh/getzlab-signatureanalyzer/signatureanalyzer/ref/cosmic_V3"

REF_PATH = "/users/kunwarsingh/getzlab-signatureanalyzer/signatureanalyzer/ref/cosmic_V3/sa_cosmic3_sbs_exome.tsv">>> MAF_PATH = "/users/kunwarsingh/output-hg38/CCGL/CCGL_somatic.maf"

HG_PATH = "/users/kunwarsingh/hg38.2bit"

SIG_LIST = ['SBS1','SBS2','SBS3']

MAX_ITER = 30000

spectra_df = sa.spectra.get_spectra_from_maf(maf, hgfile=HG_PATH, reference=REF)[1]

Traceback (most recent call last):

File "/Users/kunwarsingh/Library/Python/3.9/lib/python/site-packages/pandas/core/indexes/base.py", line 3361, in get_loc

return self._engine.get_loc(casted_key)

File "pandas/_libs/index.pyx", line 76, in pandas._libs.index.IndexEngine.get_loc

File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc

File "pandas/_libs/hashtable_class_helper.pxi", line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item

File "pandas/_libs/hashtable_class_helper.pxi", line 5206, in pandas._libs.hashtable.PyObjectHashTable.get_item

KeyError: 'Tumor_Sample_Barcode'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "", line 1, in

File "/Users/kunwarsingh/getzlab-SignatureAnalyzer/signatureanalyzer/spectra.py", line 33, in get_spectra_from_maf

maf['sample'] = maf['Tumor_Sample_Barcode']

File "/Users/kunwarsingh/Library/Python/3.9/lib/python/site-packages/pandas/core/frame.py", line 3458, in getitem

indexer = self.columns.get_loc(key)

File "/Users/kunwarsingh/Library/Python/3.9/lib/python/site-packages/pandas/core/indexes/base.py", line 3363, in get_loc

raise KeyError(key) from err

KeyError: 'Tumor_Sample_Barcode'

On Wed, Nov 10, 2021 at 6:57 AM Shankara Anand @.***> wrote:

Are you using the most up to date version? Maybe try installing the dev version with these instructions: https://github.com/getzlab/getzlab-SignatureAnalyzer#git-clone

The function call has thereference kwarg:

https://github.com/getzlab/getzlab-SignatureAnalyzer/blob/94c8a98209c400095862b538b843d82ea47dd8b9/signatureanalyzer/spectra.py#L10

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/getzlab/getzlab-SignatureAnalyzer/issues/36#issuecomment-965330201, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLDQSQLQEGFMXQBUNX4Y5LULKB4RANCNFSM5HUQPLLA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

ksingh1119 commented 2 years ago

Good morning,

I just wanted to follow up if you have any suggestions on how to fix this issue, thank you for your help and I hope you have a wonderful day!

Kunwar

On Wed, Nov 10, 2021 at 3:09 PM Kunwar Singh @.***> wrote:

Also I attached my MAF file to this email, thanks!

On Wed, Nov 10, 2021 at 3:00 PM Kunwar Singh @.***> wrote:

Hi,

I believe I was using the most updated version, I just cloned the dev version and tried to run the same supervised code in python and I am getting the original error message of tumor_sampel_barcode. Should I go back and install the pip3 version and are my pathways correct? Thanks for your help and appreciate you getting back to me so quickly. Have a wonderful day!

import pandas as pd

import signatureanalyzer as sa

REF= "/users/kunwarsingh/getzlab-signatureanalyzer/signatureanalyzer/ref/cosmic_V3"

REF_PATH = "/users/kunwarsingh/getzlab-signatureanalyzer/signatureanalyzer/ref/cosmic_V3/sa_cosmic3_sbs_exome.tsv">>> MAF_PATH = "/users/kunwarsingh/output-hg38/CCGL/CCGL_somatic.maf"

HG_PATH = "/users/kunwarsingh/hg38.2bit"

SIG_LIST = ['SBS1','SBS2','SBS3']

MAX_ITER = 30000

spectra_df = sa.spectra.get_spectra_from_maf(maf, hgfile=HG_PATH, reference=REF)[1]

Traceback (most recent call last):

File "/Users/kunwarsingh/Library/Python/3.9/lib/python/site-packages/pandas/core/indexes/base.py", line 3361, in get_loc

return self._engine.get_loc(casted_key)

File "pandas/_libs/index.pyx", line 76, in pandas._libs.index.IndexEngine.get_loc

File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc

File "pandas/_libs/hashtable_class_helper.pxi", line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item

File "pandas/_libs/hashtable_class_helper.pxi", line 5206, in pandas._libs.hashtable.PyObjectHashTable.get_item

KeyError: 'Tumor_Sample_Barcode'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "", line 1, in

File "/Users/kunwarsingh/getzlab-SignatureAnalyzer/signatureanalyzer/spectra.py", line 33, in get_spectra_from_maf

maf['sample'] = maf['Tumor_Sample_Barcode']

File "/Users/kunwarsingh/Library/Python/3.9/lib/python/site-packages/pandas/core/frame.py", line 3458, in getitem

indexer = self.columns.get_loc(key)

File "/Users/kunwarsingh/Library/Python/3.9/lib/python/site-packages/pandas/core/indexes/base.py", line 3363, in get_loc

raise KeyError(key) from err

KeyError: 'Tumor_Sample_Barcode'

On Wed, Nov 10, 2021 at 6:57 AM Shankara Anand @.***> wrote:

Are you using the most up to date version? Maybe try installing the dev version with these instructions: https://github.com/getzlab/getzlab-SignatureAnalyzer#git-clone

The function call has thereference kwarg:

https://github.com/getzlab/getzlab-SignatureAnalyzer/blob/94c8a98209c400095862b538b843d82ea47dd8b9/signatureanalyzer/spectra.py#L10

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/getzlab/getzlab-SignatureAnalyzer/issues/36#issuecomment-965330201, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLDQSQLQEGFMXQBUNX4Y5LULKB4RANCNFSM5HUQPLLA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

yoakiyama commented 2 years ago

Your input MAF file needs to have "Tumor_Sample_Barcode" as a column that labels each variant with a sample ID. This should fix your issue.

Yo

On Mon, Nov 15, 2021 at 12:56 PM ksingh1119 @.***> wrote:

Good morning,

I just wanted to follow up if you have any suggestions on how to fix this issue, thank you for your help and I hope you have a wonderful day!

Kunwar

On Wed, Nov 10, 2021 at 3:09 PM Kunwar Singh @.***> wrote:

Also I attached my MAF file to this email, thanks!

On Wed, Nov 10, 2021 at 3:00 PM Kunwar Singh @.***> wrote:

Hi,

I believe I was using the most updated version, I just cloned the dev version and tried to run the same supervised code in python and I am getting the original error message of tumor_sampel_barcode. Should I go back and install the pip3 version and are my pathways correct? Thanks for your help and appreciate you getting back to me so quickly. Have a wonderful day!

import pandas as pd

import signatureanalyzer as sa

REF=

"/users/kunwarsingh/getzlab-signatureanalyzer/signatureanalyzer/ref/cosmic_V3"

REF_PATH =

"/users/kunwarsingh/getzlab-signatureanalyzer/signatureanalyzer/ref/cosmic_V3/sa_cosmic3_sbs_exome.tsv">>> MAF_PATH = "/users/kunwarsingh/output-hg38/CCGL/CCGL_somatic.maf"

HG_PATH = "/users/kunwarsingh/hg38.2bit"

SIG_LIST = ['SBS1','SBS2','SBS3']

MAX_ITER = 30000

spectra_df = sa.spectra.get_spectra_from_maf(maf, hgfile=HG_PATH, reference=REF)[1]

Traceback (most recent call last):

File

"/Users/kunwarsingh/Library/Python/3.9/lib/python/site-packages/pandas/core/indexes/base.py", line 3361, in get_loc

return self._engine.get_loc(casted_key)

File "pandas/_libs/index.pyx", line 76, in pandas._libs.index.IndexEngine.get_loc

File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc

File "pandas/_libs/hashtable_class_helper.pxi", line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item

File "pandas/_libs/hashtable_class_helper.pxi", line 5206, in pandas._libs.hashtable.PyObjectHashTable.get_item

KeyError: 'Tumor_Sample_Barcode'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "", line 1, in

File

"/Users/kunwarsingh/getzlab-SignatureAnalyzer/signatureanalyzer/spectra.py", line 33, in get_spectra_from_maf

maf['sample'] = maf['Tumor_Sample_Barcode']

File

"/Users/kunwarsingh/Library/Python/3.9/lib/python/site-packages/pandas/core/frame.py", line 3458, in getitem

indexer = self.columns.get_loc(key)

File

"/Users/kunwarsingh/Library/Python/3.9/lib/python/site-packages/pandas/core/indexes/base.py", line 3363, in get_loc

raise KeyError(key) from err

KeyError: 'Tumor_Sample_Barcode'

On Wed, Nov 10, 2021 at 6:57 AM Shankara Anand @.***> wrote:

Are you using the most up to date version? Maybe try installing the dev version with these instructions: https://github.com/getzlab/getzlab-SignatureAnalyzer#git-clone

The function call has thereference kwarg:

https://github.com/getzlab/getzlab-SignatureAnalyzer/blob/94c8a98209c400095862b538b843d82ea47dd8b9/signatureanalyzer/spectra.py#L10

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/getzlab/getzlab-SignatureAnalyzer/issues/36#issuecomment-965330201 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AWLDQSQLQEGFMXQBUNX4Y5LULKB4RANCNFSM5HUQPLLA

. Triage notifications on the go with GitHub Mobile for iOS < https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675

or Android < https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/getzlab/getzlab-SignatureAnalyzer/issues/36#issuecomment-969169030, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJITANXHCVMLS523P5HCG7DUMFCUPANCNFSM5HUQPLLA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.