dspin 1.1.2__tar.gz → 1.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dspin
3
- Version: 1.1.2
3
+ Version: 1.3.0
4
4
  Summary: Regulatory network models from single-cell perturbation profiling
5
5
  Home-page: https://github.com/JialongJiang/DSPIN
6
6
  Author: Jialong Jiang
@@ -82,9 +82,9 @@ def automatic_david_annotation(data_folder, file_name, token_name, species='huma
82
82
 
83
83
  # Save results to Excel
84
84
  save_to_excel(data_folder, file_name,
85
- gene_id_map_reverse, num_list, full=False)
85
+ gene_id_map_reverse, all_onmf_df.columns.tolist(), full=False)
86
86
  save_to_excel(data_folder, file_name,
87
- gene_id_map_reverse, num_list, full=True)
87
+ gene_id_map_reverse, all_onmf_df.columns.tolist(), full=True)
88
88
 
89
89
 
90
90
  def make_user_prompt_with_score(genes, feature_df=[], direct=False, customized_prompt=None):
@@ -285,10 +285,10 @@ def setup_david_client(token_name):
285
285
 
286
286
  from suds.client import Client
287
287
 
288
- url = 'https://david.ncifcrf.gov/webservice/services/DAVIDWebService?wsdl'
288
+ url = 'https://davidbioinformatics.nih.gov/webservice/services/DAVIDWebService?wsdl'
289
289
  client = Client(url)
290
290
  client.wsdl.services[0].setlocation(
291
- 'https://david.ncifcrf.gov/webservice/services/DAVIDWebService.DAVIDWebServiceHttpSoap11Endpoint/')
291
+ 'https://davidbioinformatics.nih.gov/webservice/services/DAVIDWebService.DAVIDWebServiceHttpSoap11Endpoint/')
292
292
  client.service.authenticate(token_name)
293
293
  return client
294
294
 
@@ -359,7 +359,7 @@ def process_gene_lists(data_folder, file_name, all_onmf_df, gene_id_map, client)
359
359
  for i in range(num_lists):
360
360
  cur_gene_list = all_onmf_df.iloc[:, i].dropna()
361
361
  cur_gene_list = map_gene_ids(gene_id_map, cur_gene_list)
362
- save_path = os.path.join(save_folder, f'list_{i}.csv')
362
+ save_path = os.path.join(save_folder, f'list_{all_onmf_df.columns[i]}.csv')
363
363
 
364
364
  input_ids = ','.join(cur_gene_list)
365
365
  id_type = 'ENSEMBL_GENE_ID'
@@ -370,7 +370,7 @@ def process_gene_lists(data_folder, file_name, all_onmf_df, gene_id_map, client)
370
370
  term_clustering_report = client.service.getTermClusterReport(
371
371
  overlap, initialSeed, finalSeed, linkage, kappa)
372
372
 
373
- print(f'Gene list {i} ', end='\t')
373
+ print(f'Gene list {all_onmf_df.columns[i]} ', end='\t')
374
374
  # print(term_clustering_report)
375
375
  if term_clustering_report is None:
376
376
  raise Exception(
@@ -379,7 +379,7 @@ def process_gene_lists(data_folder, file_name, all_onmf_df, gene_id_map, client)
379
379
  parse_david_output(term_clustering_report, save_path)
380
380
 
381
381
 
382
- def save_to_excel(data_folder, file_name, gene_id_map_reverse, num_lists, full=True):
382
+ def save_to_excel(data_folder, file_name, gene_id_map_reverse, list_name, full=True):
383
383
  """
384
384
  Save the parsed DAVID output to an Excel file, with an option to include full or filtered results.
385
385
 
@@ -387,7 +387,7 @@ def save_to_excel(data_folder, file_name, gene_id_map_reverse, num_lists, full=T
387
387
  data_folder (str): The folder where the data files are located.
388
388
  file_name (str): The name of the original CSV file containing gene data.
389
389
  gene_id_map_reverse (dict): A dictionary mapping ENSEMBL IDs to gene symbols.
390
- num_lists (int): The number of gene lists processed.
390
+ list_name (list): A list of gene list names.
391
391
  full (bool): Whether to save the full results. If False, only results with Pvalue <= 0.05 are saved.
392
392
  """
393
393
 
@@ -433,8 +433,8 @@ def save_to_excel(data_folder, file_name, gene_id_map_reverse, num_lists, full=T
433
433
  '.csv', '_david_full.xlsx') if full else file_name.replace('.csv', '_david.xlsx')
434
434
 
435
435
  with pd.ExcelWriter(data_folder + xlsx_name) as writer:
436
- for ii in range(num_lists):
437
- cur_pd = pd.read_csv(save_folder + 'list_%d.csv' % ii, sep='\t', names=[
436
+ for lname in list_name:
437
+ cur_pd = pd.read_csv(save_folder + f'list_{lname}.csv', sep='\t', names=[
438
438
  'Category', 'Term', 'Count', '%', 'Pvalue', 'Genes', 'List Total', 'Pop Hits', 'Pop Total', 'Fold Enrichment', 'Bonferroni', 'Benjamini', 'FDR'])
439
439
  filt1 = cur_pd['Category'] == 'UP_SEQ_FEATURE'
440
440
  filt2 = cur_pd['Pvalue'].apply(filt_fun)
@@ -453,9 +453,10 @@ def save_to_excel(data_folder, file_name, gene_id_map_reverse, num_lists, full=T
453
453
  cur_pd = pd.DataFrame(np.insert(
454
454
  cur_pd.values, ind + kk, values=[" "] * len(cur_pd.columns), axis=0), columns=cur_pd.columns)
455
455
 
456
- cur_pd.to_excel(writer, sheet_name='program_%d' % ii, index=False)
457
- writer.sheets['program_%d' % ii].set_column(0, 0, 25)
458
- writer.sheets['program_%d' % ii].set_column(1, 1, 50)
459
- writer.sheets['program_%d' % ii].set_column(2, 2, 5)
460
- writer.sheets['program_%d' % ii].set_column(3, 3, 5)
461
- writer.sheets['program_%d' % ii].set_column(5, 5, 100)
456
+ sheet_name = lname
457
+ cur_pd.to_excel(writer, sheet_name=sheet_name, index=False)
458
+ writer.sheets[sheet_name].set_column(0, 0, 25)
459
+ writer.sheets[sheet_name].set_column(1, 1, 50)
460
+ writer.sheets[sheet_name].set_column(2, 2, 5)
461
+ writer.sheets[sheet_name].set_column(3, 3, 5)
462
+ writer.sheets[sheet_name].set_column(5, 5, 100)