vtraag / leidenalg

Implementation of the Leiden algorithm for various quality functions to be used with igraph in Python.
GNU General Public License v3.0
606 stars 78 forks source link

fixed_nodes on pypi #85

Closed henryrhampton closed 2 years ago

henryrhampton commented 3 years ago

Hi Vincent,

I am trying to use Northstar. I would really appreciate it if you could make a pypi release from the current master branch to simplify installation of leidenalg. I am using OSX Catalina and python 3.7.

Thanks, Henry

vtraag commented 2 years ago

I just released a new version (0.8.8) which contained just a few minor bugfixes. The fixed_nodes argument is already supported since version 0.8.0. Is there a particular problem that you are running into?

Note that the leidenalg package from PyPI does not currently support the new ARM64 on mac, compiling for it is more difficult. The package is available from the conda-forge on Anaconda for ARM64 on mac however, so that might be a good alternative. You can install it using conda install -c conda-forge leidenalg.

vtraag commented 2 years ago

If Anaconda solves this for you by the way, we could perhaps check whether @iosonofabio could also make Northstar available on conda-forge, that should make the installation even easier.

iosonofabio commented 2 years ago

Thanks Vincent, I'll try to see how to make Northstar available through conda-forge.

Henry is this fixed?

vtraag commented 2 years ago

I'll try to see how to make Northstar available through conda-forge.

It should be fairly straightforward, but if you need help, let me know.

henryrhampton commented 2 years ago

Hi, my machine is using the old Intel i5 chip rather than the new Arm64 chip. Therefore, the install from conda doesn't work on my machine. The problem i run into is that pip install leidenalg says that it works. However, the program doesn't compile successfully. I think I might be lacking a program required for compiling leidenalg

vtraag commented 2 years ago

the install from conda doesn't work on my machine

What does not work exactly? Could you post the exact commands that you run and the exact output that you get? It is difficult to help out otherwise.

The problem i run into is that pip install leidenalg says that it works. However, the program doesn't compile successfully.

If pip install leidenalg is successful, you can quickly test whether simply importing it in python works (i.e. import leidenalg). It is unclear to me what you mean by the "program doesn't compile". If pip install leidenalg is successful, it doesn't need to compile anything.

The question here is hence the same: could you post the exact commands that you run and the exact output that you get?

iosonofabio commented 2 years ago

Henry, I think Vincent is right asking for those details, it's hard to understand exactly what you're doing. I'm a bit busy these days but will take a look at the Northstar side of things.

henryrhampton commented 2 years ago

Hi Vincent,

Sorry for the late reply, I was snowed under with another task. I have been able to install version 0.8.8 of leidenalg on my mac. Furthermore, I am able to import leidenalg.

import pandas as pd
import numpy as np
import seaborn as sns
import scanpy as scanpy
import gzip as gzip
import glob as glob
import matplotlib.pyplot as plt
import northstar
from igraph import *
import leidenalg

path = 'path_to_folder/'
filenames = glob.glob(path + "/*.tsv")
adata = [scanpy.read_csv(filename, delimiter= '\t') for filename in filenames]
adata.var['GeneName'] = adata.var.index
adata.X = 1e6 * (adata.X.T / adata.X.sum(axis=1)).T

af = northstar.AtlasFetcher()
myatlas = af.fetch_atlas('TabulaMuris_2018_spleen', kind='average')
model = northstar.Averages(atlas=myatlas, n_neighbors=5,
        n_pcs=10)

When running the command I receive the error below

model.fit(new_data = adata)

TypeError: optimise_partition() got an unexpected keyword argument 'fixed_nodes'
vtraag commented 2 years ago

Sorry for the late reply, I was snowed under with another task.

Ha, any response within a week I don't call a late reply yet! My late responses are sometimes only weeks later :smile:

When running the command I receive the error below

model.fit(new_data = adata)

TypeError: optimise_partition() got an unexpected keyword argument 'fixed_nodes'

OK, thanks, this clarifies the issue. The problem is that I changed the name of fixed_nodes to is_membership_fixed to clarify it is a list of booleans. Unfortunately, I didn't consider the downstream ramifications of doing so, thereby breaking northstar (sorry @iosonofabio). This is already noted in the following issue

@iosonofabio, if I see correctly, I believe the fix is already available in your master branch, but the latest source code on PyPI (version 0.4.0) does not contain this fix yet. I guess all it takes it to make a new release @iosonofabio?

You might make northstar more robust by catching an exception when it tries to use fixed_nodes and then use is_membership_fixed instead? Or you can simply indicate a dependency on leidenalg 0.8.2 or higher.

iosonofabio commented 2 years ago

Henry just use the master branch of Northstar, I'll make a new release when I have a minute. We can close this