Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'columns' #66

Open
amini-sahand opened this issue Sep 13, 2023 · 5 comments
Open

AttributeError: 'NoneType' object has no attribute 'columns' #66

amini-sahand opened this issue Sep 13, 2023 · 5 comments

Comments

@amini-sahand
Copy link

amini-sahand commented Sep 13, 2023

Hi,
I am trying to test inferelator 3.0 on my scRNA-seq data without priors or gold standard data.
I use the following codes:

>>> worker = inferelator_workflow(regression="bbsr", workflow="single-cell")
>>> worker.set_file_paths(input_dir="E:/sa/Inferelator/input_inferelator",
                      output_dir="E:/sa/Inferelator/output_inferelator",
                      expression_matrix_file="expression.tsv",
                      tf_names_file="regulators.tsv",
                      meta_data_file="meta_data.tsv")
>>> worker.set_network_data_flags(use_no_gold_standard=True)

But I get this error when I run it:

2023-09-13 15:22:28 1 Loading TSV data file expression.tsv
2023-09-13 15:22:28 1 Loading metadata file meta_data.tsv
C:\Users\sa\pyproj\inferelator3\Lib\site-packages\anndata\_core\anndata.py:887: UserWarning:
AnnData expects .var.index to contain strings, but got values like:
    []

    Inferred to be: empty

  names = self._prep_dim_index(names, "var")
2023-09-13 15:22:28 1 Data loaded: InferelatorData [int32 (55896, 0), Metadata (55896, 1)] Memory: 0.00 MB
2023-09-13 15:22:28 1 A (0, 3748) null gold standard has been constructed
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\workflows\tfa_workflow.py", line 164, in run
    self.startup()
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\workflows\workflow_base.py", line 1290, in startup
    self.startup_run()
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\workflows\tfa_workflow.py", line 181, in startup_run
    self.process_priors_and_gold_standard()
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\workflows\workflow_base.py", line 1334, in process_priors_and_gold_standard
    self.priors_data = pm.filter_to_tf_names_list(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\preprocessing\priors.py", line 227, in filter_to_tf_names_list
    if len(priors_data.columns) == 0:
           ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'columns'

Can you please help me solve this issue?
Thanks

@asistradition
Copy link
Collaborator

worker.set_network_data_flags(
        use_no_prior=True,
        use_no_gold_standard=True
)

It would be better if you got a clearer error message, but you'll need to pass the use_no_prior flag as well. I would not expect any inference method to work without some prior knowledge of the network structure, so I would not run this without some prior network.

You also don't appear to have any loaded data:

2023-09-13 15:22:28 1 Data loaded: InferelatorData [int32 (55896, 0), Metadata (55896, 1)] Memory: 0.00 MB

I would carefully check your input data .tsv file.

@amini-sahand
Copy link
Author

Thanks. That issue is solved but apparently the other issue that you mentioned causes a new error.
My data files are not empty as you can see file sizes:

Untitled

I have a scRNA-seq expression matrix, a list of TF gene IDs, and a sample metadata that looks like this in notepad:

"isTs is1stLast prevCol del.t condName"
"FALSE NA NA NA nodulea"
"FALSE NA NA NA noduleb"
"FALSE NA NA NA nodulec"
"FALSE NA NA NA noduled"
"FALSE NA NA NA nodulee"
"FALSE NA NA NA nodulef"
"FALSE NA NA NA noduleg"
"FALSE NA NA NA noduleh"
"FALSE NA NA NA nodulei"
"FALSE NA NA NA nodulej"
"FALSE NA NA NA nodulek"

Then I got this error:

2023-09-13 16:41:21 1 Loading TSV data file expression.tsv
2023-09-13 16:41:21 1 Loading metadata file meta_data.tsv
C:\Users\sa\pyproj\inferelator3\Lib\site-packages\anndata\_core\anndata.py:887: UserWarning:
AnnData expects .var.index to contain strings, but got values like:
    []

    Inferred to be: empty

  names = self._prep_dim_index(names, "var")
2023-09-13 16:41:22 1 Data loaded: InferelatorData [int32 (55896, 0), Metadata (55896, 1)] Memory: 0.00 MB
2023-09-13 16:41:22 1 A (0, 3747) null prior has been created
2023-09-13 16:41:22 1 A (0, 3747) null gold standard has been constructed
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\workflows\tfa_workflow.py", line 164, in run
    self.startup()
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\workflows\workflow_base.py", line 1290, in startup
    self.startup_run()
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\workflows\tfa_workflow.py", line 181, in startup_run
    self.process_priors_and_gold_standard()
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\workflows\workflow_base.py", line 1349, in process_priors_and_gold_standard
    self.filter_to_gene_list()
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\workflows\workflow_base.py", line 1376, in filter_to_gene_list
    self.data.trim_genes(trim_gene_list=self.gene_names)
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\utils\inferelator_data.py", line 483, in trim_genes
    raise ValueError(
ValueError: No genes remain after trimming. (0 removed to match list, 0 removed for zero variance)

Do you have any idea why this happens?

@asistradition
Copy link
Collaborator

I would guess that the expression data is oriented as Genes x Samples. There is a flag if you're providing data where the columns aren't genes.

worker.set_file_properties(
    expression_matrix_columns_are_genes=False
)

@amini-sahand
Copy link
Author

Thanks, it helped.
I used a prior file but all with 0 values to solve another error about lack of prior data.

But after completing 5 bootstraps, I got the following IndexError:

2023-09-14 14:42:16 1 GS: 0 edges; Confidences: 189554 edges
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\workflows\tfa_workflow.py", line 170, in run
    return self.emit_results(
           ^^^^^^^^^^^^^^^^^^
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\workflows\tfa_workflow.py", line 301, in emit_results
    self.results = rp.summarize_network(
                   ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\postprocessing\results_processor.py", line 161, in summarize_network
    m_name, score = rs_calc.score()
                    ^^^^^^^^^^^^^^^
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\postprocessing\model_metrics.py", line 74, in score
    return self.name, self.aupr
                      ^^^^^^^^^
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\postprocessing\precision_recall.py", line 31, in aupr
    return self.calculate_aupr(self.filtered_data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\postprocessing\precision_recall.py", line 171, in calculate_aupr
    recall, precision = RankSummaryPR.modify_pr(data)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\inferelator\postprocessing\precision_recall.py", line 165, in modify_pr
    precision = np.insert(data[PRECISION_COLUMN].values, 0, data[PRECISION_COLUMN].iloc[0])
                                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\pandas\core\indexing.py", line 1153, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\pandas\core\indexing.py", line 1714, in _getitem_axis
    self._validate_integer(key, axis)
  File "C:\Users\sa\pyproj\inferelator3\Lib\site-packages\pandas\core\indexing.py", line 1647, in _validate_integer
    raise IndexError("single positional indexer is out-of-bounds")
IndexError: single positional indexer is out-of-bounds

Can you please help me with this one too?
Thanks

@asistradition
Copy link
Collaborator

There is an inconsistency between your expression data and the network data which you have provided.

I would strongly encourage you to not attempt to run this without prior network knowledge, but if you feel that you absolutely must, use the network flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants