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

For compatibility with newer versions of pandas, use items() instead … #115

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,14 @@ ENV/

# Visual Studio Code configuration
.vscode

# Cplex installer and installation (generated by install.sh)
cplex_studio2211.linux_x86_64.bin
cplex_studio2211/

# # Compass cache, test, and output files (generated by test.sh)
_tmp/
expression.tsv
model.json.gz
reactions.tsv
compass/Resources/COMPASS/RECON2_mat/default-media/preprocess.json
6 changes: 3 additions & 3 deletions compass/compass/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def compass_exchange(model, problem, reaction_penalties, only_exchange=False, pe
if(problem.objective.get_name() != 'reaction_penalties'):
utils.reset_objective(problem)
problem.objective.set_linear(
list(reaction_penalties.iteritems())
list(reaction_penalties.items())
)
problem.objective.set_name('reaction_penalties')
problem.objective.set_sense(problem.objective.sense.minimize)
Expand Down Expand Up @@ -414,7 +414,7 @@ def compass_exchange(model, problem, reaction_penalties, only_exchange=False, pe
if(problem.objective.get_name() != 'reaction_penalties'):
utils.reset_objective(problem)
problem.objective.set_linear(
list(reaction_penalties.iteritems())
list(reaction_penalties.items())
)
problem.objective.set_name('reaction_penalties')
problem.objective.set_sense(problem.objective.sense.minimize)
Expand Down Expand Up @@ -522,7 +522,7 @@ def compass_reactions(model, problem, reaction_penalties, perf_log=None, args =
if(problem.objective.get_name() != 'reaction_penalties'):
utils.reset_objective(problem)
problem.objective.set_linear(
list(reaction_penalties.iteritems())
list(reaction_penalties.items())
)
problem.objective.set_name('reaction_penalties')
problem.objective.set_sense(problem.objective.sense.minimize)
Expand Down
2 changes: 1 addition & 1 deletion compass/compass/algorithm_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def compass_transposed(ranges, data, model, media, args):
# Minimize Penalty
utils.reset_objective(problem)
problem.objective.set_linear(
list(reaction_penalties[sample_name].iteritems())
list(reaction_penalties[sample_name].items())
)
problem.objective.set_sense(problem.objective.sense.minimize)

Expand Down
6 changes: 3 additions & 3 deletions compass/compass/microclustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def filterGenesThreshold(data, threshold):

def filterGenesFano(data, num_mad=2):
#Could sample columns at random to improve runtime
mu = data.mean(axis=1).ravel()
fano = data.var(axis=1).ravel() / mu
mu = data.mean(axis=1).to_numpy()
fano = data.var(axis=1).to_numpy() / mu

mu_argsort = np.argsort(mu)
mu_sort = mu[mu_argsort]
Expand Down Expand Up @@ -178,7 +178,7 @@ def pool_matrix_cols(data, pools):
for i in pools[g]:
groups[data.columns[i]] = g
groups = pd.DataFrame.from_dict(groups, orient='index', columns=['compass_microcluster']).T
return data.append(groups).T.groupby("compass_microcluster").mean().T.rename(mapper=lambda x: 'cluster_'+str(int(x)), axis=1)
return pd.concat([data, groups]).T.groupby("compass_microcluster").mean().T.rename(mapper=lambda x: 'cluster_'+str(int(x)), axis=1)

def unpool_columns(pooled_data, pools, data):
unpooled_cols = []
Expand Down
2 changes: 1 addition & 1 deletion compass/compass/penalties.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def eval_reaction_penalties_shared(model, expression,
# Compute reaction expression for each sample

reaction_expression = []
for name, expression_data in expression.iteritems():
for name, expression_data in expression.items():
reaction_expression.append(
eval_reaction_expression_single(
model, expression_data, and_function
Expand Down
22 changes: 22 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -e # Exit immediately if a command exits with a non-zero status.
set -u # Treat unset variables as an error.

# Set the Cplex installer name and the install path for Cplex.
CPLEX_INSTALLER="cplex_studio2211.linux_x86_64.bin"
CPLEX_INSTALL_DIR="cplex_studio2211"
CPLEX_INSTALL_PATH=$(realpath "${CPLEX_INSTALL_DIR}")

# Set up virtual environment.
python3 -m venv .env
# shellcheck disable=SC1091
source .env/bin/activate

# Install Cplex and its Python API.
chmod u+x "${CPLEX_INSTALLER}"
"./${CPLEX_INSTALLER}" -i silent -DINSTALLER_UI=silent -DLICENSE_ACCEPTED=TRUE -DUSER_INSTALL_DIR="${CPLEX_INSTALL_PATH}"
python3 "${CPLEX_INSTALL_PATH}/python/setup.py" install

# Install Compass.
pip3 install --editable .
18 changes: 18 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -e # Exit immediately if a command exits with a non-zero status.

# Activate the environment generated by install.sh.
# shellcheck disable=SC1091
source .env/bin/activate

# Download the test data.
gdown https://raw.githubusercontent.com/YosefLab/Compass/refs/heads/master/compass/Resources/Test-Data/tsv_format/expression.tsv

# Run Compass.
compass --num-thread 32 --data expression.tsv --species homo_sapiens

# Clean up.
rm expression.tsv
rm model.json.gz
rm reactions.tsv