-
Notifications
You must be signed in to change notification settings - Fork 36
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
real_multi_modality #459
Open
xingzhongyu
wants to merge
398
commits into
main
Choose a base branch
from
celltype_annotation_automl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
real_multi_modality #459
Changes from all commits
Commits
Show all changes
398 commits
Select commit
Hold shift + click to select a range
612c72b
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 06f85e7
update scdeepsort
xingzhongyu adfbfd2
minor
xingzhongyu 5043ffc
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 95b2883
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 13a42e0
minor
xingzhongyu 059a9f4
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu c0cd31b
minor
xingzhongyu da1bfe7
minor
xingzhongyu 8a27fc6
minor
xingzhongyu 43d4894
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] def68be
minor
xingzhongyu ad8ecb7
minor
xingzhongyu 6d0583c
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 8fc8f62
update data
xingzhongyu 02893d5
minor
xingzhongyu 75a20b8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 75c6429
minor
xingzhongyu b265ec7
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 9eba40a
minor
xingzhongyu 1f6e315
Merge branch 'celltype_annotation_automl' of https://github.com/Omics…
xingzhongyu 3edaa6d
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu cdeebd9
minor
xingzhongyu 225b655
minor
xingzhongyu f70ee3e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 5645a6a
update example
xingzhongyu 06d282d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] cee9204
minor
xingzhongyu ed0b6b4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a19a050
minor
xingzhongyu 324714f
minor
xingzhongyu 33eaa23
minor
xingzhongyu b08ce14
minor
xingzhongyu 20ed44d
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 1ad3cec
minor
xingzhongyu c26f490
minor
xingzhongyu fba1880
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 467d4a0
minor
xingzhongyu 30eb4fd
minor
xingzhongyu 2d4070d
update scdeepsort
xingzhongyu da9b8a6
minor
xingzhongyu 3881988
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 27d9817
ignore result
xingzhongyu 9b6babe
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu f42e6fc
minor
xingzhongyu 83fe348
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 66923ab
minor
xingzhongyu 5859db7
minor
xingzhongyu 00e11fc
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 00c1b82
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7bbef3e
update pre-commit
xingzhongyu 828a180
Merge branch 'celltype_annotation_automl' of https://github.com/Omics…
xingzhongyu 505e5d6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b7683af
minor
xingzhongyu 7026ee0
minor
xingzhongyu d7c63ad
minor
xingzhongyu 79ce92a
Merge branch 'celltype_annotation_automl' of https://github.com/Omics…
xingzhongyu 81b8330
update data
xingzhongyu 7f37be4
update notes
xingzhongyu 3e23afc
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 7599124
update forest and other minor changes
xingzhongyu 8e1d33f
minor
xingzhongyu 1087e3c
minor
xingzhongyu 1e843d3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 46b5cb4
minor
xingzhongyu 38b0f11
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 10f8299
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] f6b3989
add scmvae
xingzhongyu d0c5c07
minor
xingzhongyu 2e6de34
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 577919a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c7169eb
minor
xingzhongyu fa7be0a
minor
xingzhongyu a66bf43
add note
xingzhongyu 9446566
Merge branch 'celltype_annotation_automl' of https://github.com/Omics…
xingzhongyu 7849333
minor
xingzhongyu 1b8dd47
minor
xingzhongyu e420a6d
translate notes
xingzhongyu 67fb57b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d452973
add argument preprocess
xingzhongyu e87e1f6
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 631ce66
add argument preprocess
xingzhongyu 0f3c268
translate notes
xingzhongyu c33f9e2
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 5355130
translate notes
xingzhongyu 7c8c657
add atlas
xingzhongyu c131db2
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 7738d7d
minor
xingzhongyu 35b105c
add atlas
xingzhongyu 4d3a0d2
update scdeepsort
xingzhongyu c7ac320
minor
xingzhongyu 2cf8e36
minor
xingzhongyu 5b3d2de
minor
xingzhongyu a18f3ae
add notes
xingzhongyu dbd1fa3
add notes
xingzhongyu b096c25
add note
xingzhongyu 4fb6145
add notes
xingzhongyu 059984e
add notes
xingzhongyu 1049349
add notes
xingzhongyu 609db04
translate notes
xingzhongyu b26151f
add notes
xingzhongyu 6878afa
add notes
xingzhongyu 04ab7eb
add notes
xingzhongyu 844d883
add notes
xingzhongyu 1512c01
add notes
xingzhongyu 7549f1d
minor
xingzhongyu f0b8db4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3c3f527
minor
xingzhongyu bc037a7
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 93d96c1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e2bd540
minor
xingzhongyu 312ab95
minor
xingzhongyu b5a6a22
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 5e51a66
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1a98457
minor
xingzhongyu 4220db0
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu a19aa53
update data
xingzhongyu aa664c9
add data
xingzhongyu 3c66081
minor
xingzhongyu c2e6aa9
update data
xingzhongyu fc3213f
add yamls
xingzhongyu 3fc9e3d
Merge branch 'celltype_annotation_automl' of https://github.com/Omics…
xingzhongyu b5d738c
add yamls
xingzhongyu d276716
merge
xingzhongyu 629e065
minor
xingzhongyu 60711e0
add yamls
xingzhongyu ca1f837
minor
xingzhongyu 9df3dfe
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 5b03b8d
minor
xingzhongyu b308093
merge
xingzhongyu 745d058
add yamls
xingzhongyu b32bf75
update data
xingzhongyu 814f39e
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu ef30006
update get_result_web
xingzhongyu 4543d1c
minor
xingzhongyu 9345b19
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b27e312
update run config
xingzhongyu add42ca
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 2f6cf01
minor
xingzhongyu f1ea675
update config
xingzhongyu a3d0aa6
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 978ce1c
minor
xingzhongyu aae2315
Merge branch 'celltype_annotation_automl' of https://github.com/Omics…
xingzhongyu ca00a8d
update result web
xingzhongyu 6f6612f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 42a42c8
update data
xingzhongyu 742ec97
update data
xingzhongyu 7785022
update ans
xingzhongyu 3c7b91d
Merge branch 'celltype_annotation_automl' of https://github.com/Omics…
xingzhongyu 3344477
update config
xingzhongyu b686b37
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 0f2b6a4
update ans
xingzhongyu 3bc9f79
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu a7313ea
delete a file or dir
xingzhongyu 933f1bc
update ans
xingzhongyu 20adea2
update config
xingzhongyu 3e61695
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 74394c8
update ans
xingzhongyu ebc1d80
update ans
xingzhongyu bd021c2
update ans
xingzhongyu 88a1ed8
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 29611b2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b5c6af1
update ans
xingzhongyu 9f3218a
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu a53558f
update ans
xingzhongyu 6e2c17f
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu b011926
update ans
xingzhongyu 64a4c7a
Merge branch 'celltype_annotation_automl' of https://github.com/Omics…
xingzhongyu a2f9ac2
update ans
xingzhongyu 60cf01a
Merge branch 'celltype_annotation_automl' of https://github.com/Omics…
xingzhongyu ce36094
update ans
xingzhongyu 13cc17f
update ans
xingzhongyu f20cdd0
update ans
xingzhongyu 192621f
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 95b1e97
update ans
xingzhongyu 1150e12
update ans
xingzhongyu c69f3c1
update ans
xingzhongyu 3dcdf78
Merge branch 'celltype_annotation_automl' of https://github.com/Omics…
xingzhongyu 39a3a71
update ans
xingzhongyu f31da9f
update ans
xingzhongyu ded0576
update ans
xingzhongyu 610425f
update ans
xingzhongyu 52480a7
Merge branch 'celltype_annotation_automl' of https://github.com/Omics…
xingzhongyu 0f345ef
update ans
xingzhongyu 95b241b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 10fda95
update ans
xingzhongyu 50fd98d
update ans
xingzhongyu 529de4c
update ans
xingzhongyu 7bd4246
update ans
xingzhongyu dd7540c
update main
xingzhongyu eda1fff
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] ed4a62b
update ans
xingzhongyu 7cb693a
update ans
xingzhongyu 36d6412
update ans
xingzhongyu bcf4492
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 66af9da
update ans
xingzhongyu ab917f0
update ans
xingzhongyu 2b68b1b
update ans
xingzhongyu ff02cf7
minor
xingzhongyu 3aa929d
Merge branch 'celltype_annotation_automl' of https://github.com/Omics…
xingzhongyu afa7fc8
update ans
xingzhongyu 3ed6a96
update ans
xingzhongyu 0edb02b
update ans
xingzhongyu f56e2fd
update ans
xingzhongyu 66cfc67
update ans
xingzhongyu e6faa66
update ans
xingzhongyu b70e71f
update ans
xingzhongyu 0812e66
update ans
xingzhongyu 00380dc
update ans
xingzhongyu 5a8a162
update ans
xingzhongyu 9a291e7
update ans
xingzhongyu 431edc1
update ans
xingzhongyu 3d3516c
update ans
xingzhongyu 60d4731
update ans
xingzhongyu a531ab9
update ans
xingzhongyu b11b5aa
update ans
xingzhongyu f7925c6
update ans
xingzhongyu 1d7bb5b
update ans
xingzhongyu cc9a683
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu fd17d42
update ans
xingzhongyu 159c4b7
update ans
xingzhongyu 1f7f13f
update ans
xingzhongyu 81a4982
update ans
xingzhongyu caf70c0
update ans
xingzhongyu e08eec4
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu fd3e9a3
update ans
xingzhongyu 9e8fb85
update ans
xingzhongyu 01f159c
update ans
xingzhongyu cdd9c50
update ans
xingzhongyu 518d9ca
update ans
xingzhongyu 087c40d
update ans
xingzhongyu c4c9889
update ans
xingzhongyu 135136c
update ans
xingzhongyu e8d2817
update ans
xingzhongyu 6b6f79b
update ans
xingzhongyu ee334bb
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 58d2b20
update ans
xingzhongyu 5b99078
update ans
xingzhongyu 2b82fd6
update ans
xingzhongyu f4e6965
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu 561025f
update ans
xingzhongyu 790e5d9
update ans
xingzhongyu 0a9a2d3
update ans
xingzhongyu 7e7d158
update ans
xingzhongyu 7ab9272
update ans
xingzhongyu af633a2
update ans
xingzhongyu 0ee8d40
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3e24fcd
update ans
xingzhongyu c611304
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu ffc84b2
Merge remote-tracking branch 'origin/celltype_annotation_automl' into…
xingzhongyu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
import json | ||
import os | ||
import pathlib | ||
|
||
import dropbox | ||
import numpy as np | ||
import pandas as pd | ||
import scanpy as sc | ||
from dropbox.exceptions import ApiError, AuthError | ||
|
||
from dance.utils import logger | ||
|
||
|
||
def upload_file_to_dropbox(dropbox_path, access_token, local_path): | ||
"""Upload a local file to Dropbox. | ||
|
||
Parameters | ||
---------- | ||
dropbox_path : str | ||
Destination path in Dropbox | ||
access_token : str | ||
Dropbox API access token | ||
local_path : str or pathlib.Path | ||
Path to local file to upload | ||
|
||
Returns | ||
------- | ||
None | ||
Returns None if upload fails | ||
|
||
""" | ||
dbx = dropbox.Dropbox(access_token) | ||
|
||
# Verify access token | ||
try: | ||
dbx.users_get_current_account() | ||
except AuthError as err: | ||
print("ERROR: Invalid access token; please check your access token.") | ||
return None | ||
try: | ||
file_upload(dbx=dbx, local_path=local_path, remote_path=dropbox_path) | ||
print("Upload successful.") | ||
except ApiError as err: | ||
print(f"API error: {err}") | ||
return None | ||
|
||
|
||
def file_upload(dbx: dropbox.Dropbox, local_path: pathlib.Path, remote_path: str): | ||
"""Upload large files to Dropbox using chunked upload. | ||
|
||
Parameters | ||
---------- | ||
dbx : dropbox.Dropbox | ||
Authenticated Dropbox client | ||
local_path : pathlib.Path | ||
Path to local file | ||
remote_path : str | ||
Destination path in Dropbox | ||
|
||
""" | ||
CHUNKSIZE = 100 * 1024 * 1024 | ||
upload_session_start_result = dbx.files_upload_session_start(b'') | ||
cursor = dropbox.files.UploadSessionCursor(session_id=upload_session_start_result.session_id, offset=0) | ||
with local_path.open("rb") as f: | ||
while True: | ||
data = f.read(CHUNKSIZE) | ||
if data == b"": | ||
break | ||
logger.debug("Pushing %d bytes", len(data)) | ||
dbx.files_upload_session_append_v2(data, cursor) | ||
cursor.offset += len(data) | ||
commit = dropbox.files.CommitInfo(path=remote_path) | ||
dbx.files_upload_session_finish(b'', cursor, commit) | ||
|
||
|
||
def create_shared_link(dbx, dropbox_path): | ||
"""Create or get existing shared link. | ||
|
||
:param dbx: Dropbox object | ||
:param dropbox_path: File path on Dropbox | ||
:return: Shared link URL | ||
|
||
""" | ||
try: | ||
links = dbx.sharing_list_shared_links(path=dropbox_path, direct_only=True).links | ||
if links: | ||
# If shared link already exists, return the first one | ||
return links[0].url | ||
else: | ||
# Create a new shared link | ||
link = dbx.sharing_create_shared_link_with_settings(dropbox_path) | ||
return link.url | ||
except ApiError as err: | ||
print(f"Error creating shared link: {err}") | ||
return None | ||
|
||
|
||
def get_link(data_fname, local_path, ACCESS_TOKEN, DROPBOX_DEST_PATH): | ||
DROPBOX_DEST_PATH = DROPBOX_DEST_PATH + "/" + data_fname | ||
|
||
upload_file_to_dropbox(dropbox_path=DROPBOX_DEST_PATH, access_token=ACCESS_TOKEN, local_path=local_path) | ||
|
||
# Create Dropbox object to get shared link | ||
dbx = dropbox.Dropbox(ACCESS_TOKEN) | ||
# Get shared link | ||
shared_link = create_shared_link(dbx, DROPBOX_DEST_PATH) | ||
if shared_link: | ||
# Dropbox shared link defaults to `dl=0` at the end, which means preview in browser. | ||
# change it to `dl=1`. | ||
download_link = shared_link.replace('&dl=0', '&dl=1') | ||
print(f"Download link: {download_link}") | ||
return download_link | ||
else: | ||
print("Unable to get shared link.") | ||
|
||
|
||
def get_ans(data: sc.AnnData, tissue: str, dataset_id: str, local_path, ACCESS_TOKEN, DROPBOX_DEST_PATH): | ||
"""Generate metadata dictionary for dataset and upload to Dropbox. | ||
|
||
Parameters | ||
---------- | ||
data : sc.AnnData | ||
Annotated data matrix | ||
tissue : str | ||
Tissue type | ||
dataset_id : str | ||
Unique identifier for dataset | ||
local_path : str or pathlib.Path | ||
Path to local data file | ||
ACCESS_TOKEN : str | ||
Dropbox API access token | ||
DROPBOX_DEST_PATH : str | ||
Base path in Dropbox for uploads | ||
|
||
Returns | ||
------- | ||
dict | ||
Metadata dictionary containing dataset information and Dropbox URLs | ||
|
||
""" | ||
# keys=["species","tissue","dataset","split","celltype_fname","celltype_url","data_fname","data_url"] | ||
# Create metadata dictionary with dataset info | ||
ans = {} | ||
ans["species"] = "human" | ||
ans["tissue"] = tissue.capitalize() | ||
# Store number of observations (cells) in dataset | ||
ans["dataset"] = data.n_obs | ||
ans["split"] = "train" | ||
ans["celltype_fname"] = "" | ||
ans["celltype_url"] = "" | ||
ans["data_fname"] = f"train_human_{tissue.capitalize()}{dataset_id}_data.h5ad" | ||
ans["data_url"] = get_link(data_fname=ans["data_fname"].split("_", 1)[1], local_path=local_path, | ||
ACCESS_TOKEN=ACCESS_TOKEN, DROPBOX_DEST_PATH=DROPBOX_DEST_PATH) | ||
ans["is_ALL_Integer"] = np.all(np.equal(data.X.data, data.X.data.astype(int))) | ||
return ans |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see PyCQA/docformatter#287