aboutsummaryrefslogtreecommitdiff
path: root/gn3
AgeCommit message (Collapse)Author
2021-12-02Implement dataset metadata API endpoint.Arun Isaac
* guix.scm: Import (gnu packages rdf). (genenetwork3)[propagated-inputs]: Add python-sparqlwrapper. * gn3/settings.py (SPARQL_ENDPOINT): New variable. * gn3/api/general.py: Import datasets from gn3.db. (dataset_metadata): New API endpoint. * gn3/db/datasets.py: Import re, Template from string, Dict and Optional from typing, JSON and SPARQLWrapper from SPARQLWrapper, SPARQL_ENDPOINT from gn3.settings. (sparql_query, dataset_metadata): New functions.
2021-11-25db: traits: Support additions and deletions from csv fileBonfaceKilz
2021-11-24db: traits: Remove trailing ".0" in int valuesBonfaceKilz
2021-11-23db: traits: Remove "\n\n" when generating csv fileBonfaceKilz
In excel, "\n\n" is replaced with ",,,," during upload.
2021-11-20Merge pull request #56 from genenetwork/partial-correlationsMuriithi Frederick Muriuki
Partial correlations
2021-11-19Avoid rounding: compare floats approximatelyFrederick Muriuki Muriithi
Notes: https://github.com/genenetwork/genenetwork3/pull/56#issuecomment-973798918 * As mentioned in the notes, rather than rounding to an arbitrary number of decimal places, it is a much better practice to use approximate comparisons of floats for the tests.
2021-11-18Fix some linting errorsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Fix some obvious linting errors and remove obsolete code
2021-11-18Replace code migrated from R with pingouin functionsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Replace the code that was in the process of being migrated from R in GeneNetwork1 with calls to pingouin functions that achieve the same thing. Since the functions in this case are computing correlations and partial correlations, rather than having home-rolled functions to do that, this commit makes use of the tried and tested pingouin functions. This avoids complicating our code with edge-case checks, and leverages the performance optimisations done in pingouin.
2021-11-16Remove sqlalchemy.Arun Isaac
* gn3/settings.py (SQLALCHEMY_TRACK_MODIFICATIONS): Delete variable. * guix.scm (genenetwork3)[propagated-inputs]: Remove python-sqlalchemy-stubs. * setup.py: Remove sqlalchemy-stubs from install_requires.
2021-11-15Fix bugs in recursive partial correlationsFrederick Muriuki Muriithi
* gn3/computations/partial_correlations.py: Remove rounding. Fix computation of remaining covariates * tests/unit/computations/partial_correlations_test_data/pcor_rec_blackbox_test.txt: reduce the number of covariates to between one (1) and three (3) * tests/unit/computations/test_partial_correlations.py: fix some minor bugs It turns out that the computation complexity increases exponentially, with the number of covariates. Therefore, to get a somewhat sensible test time, while retaining a large-ish number of tests, this commit reduces the number of covariates to between 1 and 3.
2021-11-15Merge branch 'main' of github.com:genenetwork/genenetwork3 into ↵Frederick Muriuki Muriithi
partial-correlations
2021-11-15Fix the columns in built data frameFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * When the z value is a Sequence of sequences of values, each of the internal sequences should form a column of its own, and not a row, as it was originally set up to do.
2021-11-13Do not shadow global symbol uuid.Arun Isaac
* gn3/authentication.py (get_groups_by_user_uid): Rename local symbol uuid to group_uuid. (get_user_info_by_key): Rename local symbol uuid to user_uuid.
2021-11-13Reformat condition on a single line.Arun Isaac
* gn3/authentication.py (get_user_info_by_key): Reformat so that condition is on a single line.
2021-11-13Do not use dangerous default argument [].Arun Isaac
Default arguments get evaluated only once when the function is defined, and are then shared across all instances of the function. If the argument is then mutated, this can cause hard to find bugs. See https://docs.python.org/3/tutorial/controlflow.html#default-argument-values * gn3/authentication.py (create_group): Do not use [] as the default argument.
2021-11-12Merge branch 'main' of github.com:genenetwork/genenetwork3 into ↵Frederick Muriuki Muriithi
partial-correlations
2021-11-11Remove redundant check on the Pearson correlation coefficient.Arun Isaac
The Pearson correlation coefficient always has a value between -1 and 1. So, this check is redundant. * gn3/heatmaps.py (cluster_traits.__compute_corr): Remove redundant check on the Pearson correlation coefficient.
2021-11-11Reimplement correlations2.compute_correlation using pearsonr.Arun Isaac
correlations2.compute_correlation computes the Pearson correlation coefficient. Outsource this computation to scipy.stats.pearsonr. When the inputs are constant, the Pearson correlation coefficient does not exist and is represented by NaN. Update the tests to reflect this. * gn3/computations/correlations2.py: Remove import of sqrt from math. (compute_correlation): Reimplement using scipy.stats.pearsonr. * tests/unit/computations/test_correlation.py: Import math. (TestCorrelation.test_compute_correlation): When inputs are constant, set expected correlation coefficient to NaN.
2021-11-11Reimplement __items_with_values using list comprehension.Arun Isaac
* gn3/computations/correlations2.py: Remove import of reduce from functools. (__items_with_values): Reimplement using list comprehension.
2021-11-11pylint fixes and pep8 formattingAlexander Kabui
2021-11-11fix target and base sample data orderAlexander Kabui
2021-11-11fix:spawned processes memory issuesAlexander Kabui
2021-11-11replace list with generatorsAlexander Kabui
2021-11-09Add functions for updating groupsBonfaceKilz
2021-11-09Merge branch 'main' of github.com:genenetwork/genenetwork3 into ↵Frederick Muriuki Muriithi
partial-correlations
2021-11-09Implement remaining part of `partial_correlation_recursive` functionFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * gn3/computations/partial_correlations.py: implement remaining portion of `partial_correlation_recursive` function. * tests/unit/computations/test_partial_correlations.py: add parsing for new data format and update tests
2021-11-09Add new data processing utilityFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * gn3/data_helpers.py: New function (`partition_by`) * tests/unit/test_data_helpers.py: Tests for new function Add a function that approximates Clojure's `partition-by` function, to help with processing the data in a more functional way.
2021-11-09Fix bug: if three columns, ensure last is "z"Frederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Fix a bug, caught when the function is called in a recursive form, with the "z*" columns reducing for each cycle through the recursive form. As it was, the last cycle through the recursive form would end up with a DataFrame with the columns "x", "y", and "z0" rather than the columns "x", "y", "z". This commit handles that edge case to ensure that the column name is changed from "z0" to simply "z".
2021-11-04Create blackbox tests for some functions migrated from RFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * gn3/computations/partial_correlations.py: new stub functions (partial_correlation_matrix, partial_correlation_recursive) * tests/unit/computations/partial_correlations_test_data/pcor_mat_blackbox_test.csv: blackbox sample data and results for variance-covariance matrix method * tests/unit/computations/partial_correlations_test_data/pcor_rec_blackbox_test.csv: blackbox sample data and results for recursive method * tests/unit/computations/test_partial_correlations.py: Tests for new function Provide some blackbox testing sample data for checking the operation of the functions migrated from R.
2021-11-04Stub `determine_partials`Frederick Muriuki Muriithi
Issue: * Stub out `determine_partials` which is a migration of `web.webqtl.correlation.correlationFunction.determinePartialsByR` in GN1. The function in GN1 has R code from line 188 to line 344. This will need to be converted over to Python. This function will also need tests.
2021-11-04Implement `compute_partial_correlations_fast`Frederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Implement `compute_partial_correlations_fast` that is a partial migration of `web.webqtl.correlation.PartialCorrDBPage.getPartialCorrelationsFast` in GN1. This function will probably be reworked once the dependencies are fully migrated. It also needs tests to be added.
2021-11-04Retrieve indices of the selected samplesFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * gn3/computations/partial_correlations.py: New function (good_dataset_samples_indexes). * tests/unit/computations/test_partial_correlations.py: Tests for new function (good_dataset_samples_indexes) Get the indices of the selected samples. This is a partial migration of the `web.webqtl.correlation.PartialCorrDBPage.getPartialCorrelationsFast` function in GN1.
2021-11-04Fix some linting errorsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi
2021-11-04Parse single line from CSV fileFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * gn3/data_helpers.py: New function (parse_csv_line) * tests/unit/test_data_helpers.py: Add tests for new function (parse_csv_line) Add a function to parse a single line from a CSV file.
2021-11-04Add some condition checking functionsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Add the `check_for_literature_info` and `check_symbol_for_tissue_correlation` functions to check for the presence of specific data.
2021-11-04Explicitly round the valuesFrederick Muriuki Muriithi
* Explicitly round the values to prevent issues with the type-checker
2021-11-04Specify ten (10) decimal placesFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * gn3/computations/partial_correlations.py: specify 10 decimal places * tests/unit/computations/test_partial_correlations.py: update examples Slight differences in python implementations, possibly hardware and operating systems could cause the value of float (double) values to be different in the less significant parts of the decimal places. This commit limits the usable part of the decimals to the first 10 decimal places for now.
2021-11-04Fix linting and typing errorsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi
2021-11-04Rework sorting: remove `compare_tissue_correlation_absolute_values`Frederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * gn3/db/correlations.py: Remove the `compare_tissue_correlation_absolute_values` function which is no longer needed.
2021-11-04Complete `build_temporary_tissue_correlations_table`Frederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * gn3/computations/partial_correlations.py: Remove comments after updating usage of the function at call point * gn3/db/correlations.py: Complete the implementation of the `build_temporary_tissue_correlations_table` function
2021-11-04Complete implementation of `batch_computed_tissue_correlation`Frederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Complete the implementation of the `batch_computed_tissue_correlation` function
2021-11-04Move `correlations_of_all_tissue_traits`Frederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * gn3/computations/partial_correlations.py: new function (`correlations_of_all_tissue_traits`). * gn3/db/correlations.py: delete function (`correlations_of_all_tissue_traits`). Move the function to `gn3.computations.partial_correlations` module and comment out the db-access code. Rework it to receive, as arguments, the data it previously fetched from the database, and add comments on future rework to get the function working again.
2021-11-04Add missing commaFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi
2021-11-04Implement `tissue_correlation` functionFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * gn3/computations/partial_correlations.py: New function (tissue_correlation) * tests/unit/test_partial_correlations.py -> tests/unit/computations/test_partial_correlations.py: Move module. Implement tests for new function Migrate the `cal_tissue_corr` function embedded in the `web.webqtl.correlation.correlationFunction.batchCalTissueCorr` function in GN1 and implement tests to ensure it works correctly.
2021-11-04Move the function to computations moduleFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * The function `batch_computed_tissue_correlation` is a pure computations function with no expressions accessing the database, as far as I can tell, therefore, this commit moves the function over to the gn3.computations.partial_correlations module that holds the pure computation functions.
2021-11-04Move the partial_correlations module to gn3.computationsFrederick Muriuki Muriithi
* Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Move the partial_correlations.py module to the gn3.computations module, since it contains the computations for partial correlations.
2021-11-04Remove if clauses: replace with dictFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Remove the if clauses to simplify the code flow: use a dictionary of queries and select the appropriate query from the dictionary instead.
2021-11-04Stub out `batch_computed_tissue_correlation` functionFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Stub out `batch_computed_tissue_correlation` function to be used in implementing the function down the line.
2021-11-04Complete `correlations_of_all_tissue_traits`Frederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Complete the implementation of the `correlations_of_all_tissue_traits` function by providing a call to a non-implemented function.
2021-11-04Implement `fetch_gene_symbol_tissue_value_dict_for_trait`Frederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Implement `fetch_gene_symbol_tissue_value_dict_for_trait` function which is a migration of the `web.webqtl.correlation.correlationFunction.getGeneSymbolTissueValueDictForTrait` function in GeneNetwork1.