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

load_tf_names command not working #22

Open
Seandelao opened this issue Feb 4, 2020 · 1 comment
Open

load_tf_names command not working #22

Seandelao opened this issue Feb 4, 2020 · 1 comment

Comments

@Seandelao
Copy link

Hello,

I am trying to utilize Arboreto, but am having difficulty. I am running the following code in Jupiter Notebook:

import os
import pandas as pd

from arboreto.algo import grnboost2, genie3
from arboreto.utils import load_tf_names

if name == 'main':
ex_matrix = pd.read_csv('myDir/1.1_exprMatrix_filtered_t.txt', sep='\t')

tf_names = load_tf_names('myDir//1.1_inputTFs.txt')

network = grnboost2(expression_data=ex_matrix,
                tf_names=tf_names)

network.to_csv('myDir/sc_01_network.tsv', sep='\t', header=False, index=False)

but get an error:

----> 7 tf_names=tf_names)
...
AttributeError: 'DataFrame' object has no attribute 'as_matrix'

Is this an incompatibility with the new pandas version? I am using the following:

Pandas version: 1.0.0
arboreto version: 0.1.5

Thank you!

@jpromeror
Copy link

jpromeror commented Feb 14, 2020

Hello @Seandelao

I had the same issue when running the grnboost2 function. Im guessing that it is a problem with versions and deprecated functions.

I was able to get the function running with the following code:

import os
import glob
import pickle
import pandas as pd
import numpy as np

from dask.diagnostics import ProgressBar

from arboreto.utils import load_tf_names
from arboreto.algo import grnboost2

from pyscenic.rnkdb import FeatherRankingDatabase as RankingDatabase
from pyscenic.utils import modules_from_adjacencies, load_motifs
from pyscenic.prune import prune2df, df2regulons
from pyscenic.aucell import aucell
from pyscenic.binarization import binarize
from pyscenic.cli.utils import save_enriched_motifs

import seaborn as sns

# Define some variables
DATA_FOLDER="/home/jpromero/Data/SCENIC/"
SC_EXP_FNAME = os.path.join(DATA_FOLDER, "Exp_mat.csv")

# Load the expression matrix

ex_matrix = pd.read_csv(SC_EXP_FNAME ,index_col=0)
ex_matrix.head()
ex_matrix.shape

#  list of Transcription Factors(TF) 
tf_names = load_tf_names(MM_TFS_FNAME)
tf_names[:5]

# Transfrom Pandas DataFrame into Numpy array 
ExpMat=ex_matrix.values

# Get gene names 
Genes=ex_matrix.columns.values

# Run grnboost2
adjacencies = grnboost2(ExpMat,gene_names=Genes, tf_names=tf_names, verbose=True)


Hope this helps!

Juan Pablo

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