Skip to content

Commit

Permalink
Remove docs from .gitignore and add to Git
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsWinter committed Dec 10, 2024
1 parent 751bcc9 commit 30a9b27
Show file tree
Hide file tree
Showing 21 changed files with 215 additions and 296 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

docs

examples/tmp
examples/simulated_data
Expand Down
3 changes: 3 additions & 0 deletions documentation/docs/api/cpm_regression.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CPM Regression

::: cpm.cpm_analysis
3 changes: 3 additions & 0 deletions documentation/docs/api/edge_selection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Edge Selection

::: cpm.edge_selection
3 changes: 3 additions & 0 deletions documentation/docs/api/fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Fold

::: cpm.fold
3 changes: 3 additions & 0 deletions documentation/docs/api/models.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Predictive Models

::: cpm.models
Binary file added documentation/docs/assets/img/CCCPM.pdf
Binary file not shown.
Binary file added documentation/docs/assets/img/CCCPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/docs/assets/img/CCCPM_large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/docs/assets/img/CCCPM_medium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions documentation/docs/examples/human_connectome_project.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```python
--8<-- "examples/hcp_analysis.py"
```
3 changes: 3 additions & 0 deletions documentation/docs/examples/simulated_data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```python
--8<-- "examples/example_simulated_data.py"
```
12 changes: 12 additions & 0 deletions documentation/docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
:root {
--md-primary-fg-color: #257180;
--md-primary-fg-color--light: #257180;
--md-primary-fg-color--dark: #257180;
--md-accent-fg-color: #FD8B51;
--md-accent-fg-color--transparent: #FD8B51;
--md-accent-bg-color: #FD8B51;
--md-accent-bg-color--light: #FD8B51;
}
:root > * {
--md-code-bg-color: rgb(242, 229, 191, 0.3);
}
32 changes: 32 additions & 0 deletions examples/example_simulated_data3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from sklearn.model_selection import KFold, ShuffleSplit, RepeatedKFold

from cpm import CPMRegression
from cpm.simulate_data import simulate_regression_data_2
from cpm.edge_selection import PThreshold, UnivariateEdgeSelection


link_types = ['no_link',
'no_no_link',
'direct_link',
'weak_link'
]
edge_statistics = ['pearson', 'pearson_partial']
results_folder = '/spm-data/vault-data3/mmll/projects/confound_corrected_cpm/results'

for link in link_types:
for edge_statistic in edge_statistics:
X, y, covariates = simulate_regression_data_2(n_features=1225, n_informative_features=50, link_type=link)

univariate_edge_selection = UnivariateEdgeSelection(edge_statistic=[edge_statistic],
edge_selection=[PThreshold(threshold=[0.05],
correction=['fdr_by'])])
cpm = CPMRegression(results_directory=f'{results_folder}/simulated_data_{link}_{edge_statistic}',
cv=RepeatedKFold(n_splits=10, n_repeats=5, random_state=42),
edge_selection=univariate_edge_selection,
inner_cv=ShuffleSplit(n_splits=3, test_size=0.2, random_state=42),
add_edge_filter=True,
n_permutations=2)
cpm.estimate(X=X, y=y, covariates=covariates)

#cpm._calculate_permutation_results('./tmp/example_simulated_data2')

38 changes: 0 additions & 38 deletions examples/hannah.py

This file was deleted.

62 changes: 0 additions & 62 deletions examples/hcp_analysis.py

This file was deleted.

49 changes: 0 additions & 49 deletions examples/human_connectome_project.py

This file was deleted.

62 changes: 0 additions & 62 deletions examples/macs.py

This file was deleted.

42 changes: 42 additions & 0 deletions examples/plot_simulation_results2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd


results_folder = "simulated_data"
edge_statistics = ['pearson', 'pearson_partial']


for scenario in ['A', 'B']:
for edge_statistic in edge_statistics:
results = {f"scenario_{scenario}1": os.path.join(results_folder, f"scenario_{scenario}1", "results", edge_statistic),
f"scenario_{scenario}2": os.path.join(results_folder, f"scenario_{scenario}2", "results", edge_statistic),
f"scenario_{scenario}3": os.path.join(results_folder, f"scenario_{scenario}3", "results", edge_statistic),
f"scenario_{scenario}4": os.path.join(results_folder, f"scenario_{scenario}4", "results", edge_statistic),
}

dfs = []
for link_type, folder in results.items():
df = pd.read_csv(os.path.join(folder, 'cv_results.csv'))
df['link_type'] = link_type
dfs.append(df)

concatenated_df = pd.concat(dfs, ignore_index=True)

concatenated_df = concatenated_df[concatenated_df['network'] == 'both']


g = sns.FacetGrid(concatenated_df, col="link_type", margin_titles=True, despine=True,
height=2.5, hue="model")
g.map(plt.axvline, x=0, color='grey', linewidth=0.5, zorder=-1)
g.map(sns.violinplot, "pearson_score", "model", inner=None, split=True,# hue="model",# hue_order=[1, 2],
density_norm='count', dodge=True, palette="Blues_r", fill=True)
#g.map(sns.boxplot, "pearson_score", "model", dodge=True, #hue=1, hue_order=[2, 1]
# )
g.set_titles(col_template="{col_name}", size=7)
g.set_xlabels("Pearson correlation", size=8)
plt.suptitle(edge_statistic)
plt.show()
print()
2 changes: 1 addition & 1 deletion examples/save_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
cpm = CPMRegression(results_directory='./tmp/example_simulated_data2',
cv=KFold(n_splits=5, shuffle=True, random_state=42),
edge_selection=univariate_edge_selection,
cv_edge_selection=ShuffleSplit(n_splits=1, test_size=0.2, random_state=42),
inner_cv=ShuffleSplit(n_splits=1, test_size=0.2, random_state=42),
add_edge_filter=True,
n_permutations=100)
cpm.save_configuration(config_filename='./config.pkl')
Expand Down
Loading

0 comments on commit 30a9b27

Please sign in to comment.