AllonKleinLab / cospar

MIT License
26 stars 6 forks source link

infer_Tmap_from_multitime_clones file saving error #20

Closed cnk113 closed 2 years ago

cnk113 commented 2 years ago

So when running infer_Tmap_from_multitime_clones It seems during the steps of saving the similarity matrix, it seems to be hardcoded to / as a result I get a permissions denied error since I don't have root access.

------Compute the full Similarity matrix if necessary------
--> Compute similarity matrix: computing new; beta=0.1
Smooth round: 1
--> Time elapsed: 0.0056591033935546875
Smooth round: 2
--> Time elapsed: 0.026040315628051758
Smooth round: 3
--> Time elapsed: 0.12216806411743164
--> Orignal sparsity=0.29680754580899055, Thresholding
--> Final sparsity=0.21954951588673013
similarity matrix truncated (Smooth round=3):  0.169694185256958
Smooth round: 4
--> Time elapsed: 0.22322940826416016
--> Orignal sparsity=0.42566835269591563, Thresholding
--> Final sparsity=0.309216775039273
similarity matrix truncated (Smooth round=4):  0.07893252372741699
Smooth round: 5
--> Time elapsed: 0.276233434677124
--> Orignal sparsity=0.4792675657523679, Thresholding
--> Final sparsity=0.3707213953949174
similarity matrix truncated (Smooth round=5):  0.09344744682312012
--> Save the matrix at every 5 rounds

---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
Cell In [152], line 1
----> 1 adata2 = cs.tmap.infer_Tmap_from_multitime_clones(
      2     adata,
      3     clonal_time_points=[0,1],
      4     sparsity_threshold=0.1,
      5     intraclone_threshold=0.2,
      6     max_iter_N=10,
      7     epsilon_converge=0.01,
      8 )

File ~/miniconda3/envs/venv/lib/python3.8/site-packages/cospar-0.2.1-py3.8.egg/cospar/tmap/map_reconstruction.py:174, in infer_Tmap_from_multitime_clones(adata_orig, clonal_time_points, later_time_point, smooth_array, CoSpar_KNN, sparsity_threshold, intraclone_threshold, normalization_mode, extend_Tmap_space, save_subset, use_full_Smatrix, trunca_threshold, compute_new, max_iter_N, epsilon_converge)
    166     similarity_file_name = os.path.join(
    167         data_path,
    168         f"{data_des}_Similarity_matrix_with_all_cell_states_kNN{CoSpar_KNN}_Truncate{temp_str}",
    169     )
    170     if not (
    171         os.path.exists(similarity_file_name + f"_SM{round_of_smooth}.npz")
    172         and (not compute_new)
    173     ):
--> 174         similarity_matrix_full = tmap_util.generate_similarity_matrix(
    175             adata_orig,
    176             similarity_file_name,
    177             round_of_smooth=round_of_smooth,
    178             neighbor_N=CoSpar_KNN,
    179             truncation_threshold=trunca_threshold[0],
    180             save_subset=save_subset,
    181             compute_new_Smatrix=compute_new,
    182         )
    184 # compute transition map between neighboring time points
    185 if later_time_point is None:

File ~/miniconda3/envs/venv/lib/python3.8/site-packages/cospar-0.2.1-py3.8.egg/cospar/tmap/_utils.py:155, in generate_similarity_matrix(adata, file_name, round_of_smooth, neighbor_N, beta, truncation_threshold, save_subset, use_existing_KNN_graph, compute_new_Smatrix)
    152     if SM % 5 == 0:  # save when SM=5,10,15,20,...
    154         logg.hint("Save the matrix at every 5 rounds")
--> 155         ssp.save_npz(file_name + f"_SM{SM}.npz", similarity_matrix)
    156 else:  # save all
    158     logg.hint("Save the matrix at every round")

File ~/miniconda3/envs/venv/lib/python3.8/site-packages/scipy/sparse/_matrix_io.py:70, in save_npz(file, matrix, compressed)
     64 arrays_dict.update(
     65     format=matrix.format.encode('ascii'),
     66     shape=matrix.shape,
     67     data=matrix.data
     68 )
     69 if compressed:
---> 70     np.savez_compressed(file, **arrays_dict)
     71 else:
     72     np.savez(file, **arrays_dict)

File <__array_function__ internals>:5, in savez_compressed(*args, **kwargs)

File ~/miniconda3/envs/venv/lib/python3.8/site-packages/numpy/lib/npyio.py:689, in savez_compressed(file, *args, **kwds)
    626 @array_function_dispatch(_savez_compressed_dispatcher)
    627 def savez_compressed(file, *args, **kwds):
    628     """
    629     Save several arrays into a single file in compressed ``.npz`` format.
    630 
   (...)
    687 
    688     """
--> 689     _savez(file, args, kwds, True)

File ~/miniconda3/envs/venv/lib/python3.8/site-packages/numpy/lib/npyio.py:715, in _savez(file, args, kwds, compress, allow_pickle, pickle_kwargs)
    712 else:
    713     compression = zipfile.ZIP_STORED
--> 715 zipf = zipfile_factory(file, mode="w", compression=compression)
    717 for key, val in namedict.items():
    718     fname = key + '.npy'

File ~/miniconda3/envs/venv/lib/python3.8/site-packages/numpy/lib/npyio.py:112, in zipfile_factory(file, *args, **kwargs)
    110 import zipfile
    111 kwargs['allowZip64'] = True
--> 112 return zipfile.ZipFile(file, *args, **kwargs)

File ~/miniconda3/envs/venv/lib/python3.8/zipfile.py:1251, in ZipFile.__init__(self, file, mode, compression, allowZip64, compresslevel, strict_timestamps)
   1249 while True:
   1250     try:
-> 1251         self.fp = io.open(file, filemode)
   1252     except OSError:
   1253         if filemode in modeDict:

PermissionError: [Errno 13] Permission denied: '/_Similarity_matrix_with_all_cell_states_kNN20_Truncate0001_SM5.npz'
ShouWenWang commented 2 years ago

It might be that the saving directory is not well configurated. Did you include this code when running?

cs.settings.data_path = "data_cospar"
cs.settings.figure_path = "fig_cospar"
cs.hf.set_up_folders()

If this does not work, could you try to run the notebook like this one? https://cospar.readthedocs.io/en/latest/20211010_preprocessing.html

cnk113 commented 2 years ago

Yah I have it at the beginning

cs.settings.data_path = "/home/chang/data_dir/cospar_data"
cs.settings.figure_path = "/home/chang/data_dir/cospar"
cs.hf.set_up_folders()

Should I not give absolute paths?

ShouWenWang commented 2 years ago

I don’t know. You have to try

Get Outlook for iOShttps://aka.ms/o0ukef


From: Chang Kim @.> Sent: Friday, September 23, 2022 4:37:57 PM To: AllonKleinLab/cospar @.> Cc: Wang, Shouwen @.>; Comment @.> Subject: Re: [AllonKleinLab/cospar] infer_Tmap_from_multitime_clones file saving error (Issue #20)

Yah I have it at the beginning

cs.settings.data_path = "/home/chang/data_dir/cospar_data" cs.settings.figure_path = "/home/chang/data_dir/cospar" cs.hf.set_up_folders()

Should I not give absolute paths?

— Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_AllonKleinLab_cospar_issues_20-23issuecomment-2D1256649535&d=DwMCaQ&c=WO-RGvefibhHBZq3fL85hQ&r=HV3hSxJneq48OyAO3fZXR0hE5NwTsotE_nsykGsxi-U&m=LnfFKTJ_wt_MV3tZDuf3xHtHsys5mzBHlIZjVHVfKl5h6IgON44IQVf2q_DMmwUk&s=jZneiTabqaVvpGoPpX6tlQ5czzCF78_3x_VWcJKqX2Q&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ABDCAST65LXX5HDRDYB2KGTV7YIKLANCNFSM6AAAAAAQTWECEM&d=DwMCaQ&c=WO-RGvefibhHBZq3fL85hQ&r=HV3hSxJneq48OyAO3fZXR0hE5NwTsotE_nsykGsxi-U&m=LnfFKTJ_wt_MV3tZDuf3xHtHsys5mzBHlIZjVHVfKl5h6IgON44IQVf2q_DMmwUk&s=6shBr-1zqtIMw2YC8_0Bm1fW58vuWM91I2n3NNxuuFA&e=. You are receiving this because you commented.Message ID: @.***>

cnk113 commented 2 years ago

Okay changing from the absolute paths fixed it!

ShouWenWang commented 2 years ago

Great!

Get Outlook for iOShttps://aka.ms/o0ukef


From: Chang Kim @.> Sent: Monday, September 26, 2022 1:43:24 AM To: AllonKleinLab/cospar @.> Cc: Wang, Shouwen @.>; Comment @.> Subject: Re: [AllonKleinLab/cospar] infer_Tmap_from_multitime_clones file saving error (Issue #20)

Okay changing from the absolute paths fixed it!

— Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_AllonKleinLab_cospar_issues_20-23issuecomment-2D1257509198&d=DwMCaQ&c=WO-RGvefibhHBZq3fL85hQ&r=HV3hSxJneq48OyAO3fZXR0hE5NwTsotE_nsykGsxi-U&m=8kvJ1RTOBISY9dzlaMdn1z8qeSyAy4uOnNyB2mKUpKlbnknxRGY83kJ6iVlSYvsD&s=WKBk5bfbnMv07bf_zUHK90ZSLg_v4wxIpeiAiuiHFFY&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ABDCASTP2VDRYBZLNLN7XY3WAEZXZANCNFSM6AAAAAAQTWECEM&d=DwMCaQ&c=WO-RGvefibhHBZq3fL85hQ&r=HV3hSxJneq48OyAO3fZXR0hE5NwTsotE_nsykGsxi-U&m=8kvJ1RTOBISY9dzlaMdn1z8qeSyAy4uOnNyB2mKUpKlbnknxRGY83kJ6iVlSYvsD&s=CUeTQ_iq6--inrri9ubqftFVPsRkYGudWiRTiscPD08&e=. You are receiving this because you commented.Message ID: @.***>