Skip to content

Commit

Permalink
add logfoldchanges, #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Min Dai committed Aug 10, 2021
1 parent 0374729 commit b6df4c0
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 29,168 deletions.
32 changes: 0 additions & 32 deletions build/lib/cosg/cosg.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
from typing import Iterable, Union, Optional


<<<<<<< HEAD

=======
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362
### Refer to: https://github.com/theislab/scanpy/blob/5533b644e796379fd146bf8e659fd49f92f718cd/scanpy/_compat.py
try:
from typing import Literal
Expand All @@ -27,17 +24,13 @@ def __getitem__(cls, values):
class Literal(metaclass=LiteralMeta):
pass

<<<<<<< HEAD
### Refer to Scanpy
=======
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362
def _select_top_n(scores, n_top):
reference_indices = np.arange(scores.shape[0], dtype=int)
partition = np.argpartition(scores, -n_top)[-n_top:]
partial_indices = np.argsort(scores[partition])[::-1]
global_indices = reference_indices[partition][partial_indices]
return global_indices
<<<<<<< HEAD


### Import from Scanpy
Expand Down Expand Up @@ -315,8 +308,6 @@ def _basic_stats(self):
# deleting the next line causes a memory leak for some reason
del X_rest

=======
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362

def cosg(
adata,
Expand All @@ -329,10 +320,7 @@ def cosg(

n_genes_user:int =50,
key_added: Optional[str] = None,
<<<<<<< HEAD
calculate_logfoldchanges: bool = True,
=======
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362
use_raw: bool = True,
layer: Optional[str] = None,
reference: str = 'rest',
Expand Down Expand Up @@ -361,11 +349,8 @@ def cosg(
The number of genes that appear in the returned tables. The default value is 50.
key_added
The key in `adata.uns` information is saved to.
<<<<<<< HEAD
calculate_logfoldchanges
Calculate logfoldchanges.
=======
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362
use_raw
Use `raw` attribute of `adata` if present.
layer
Expand Down Expand Up @@ -496,7 +481,6 @@ def cosg(
### Refer to scanpy
rank_stats=None

<<<<<<< HEAD
### Whether to calculate logfoldchanges, because this is required in scanpy 1.8
if calculate_logfoldchanges:
### Calculate basic stats
Expand All @@ -521,8 +505,6 @@ def cosg(
anndata_obj = _RankGenes(adata, groups_order2, groupby, reference, use_raw, layer, pts)
anndata_obj._basic_stats()

=======
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362

### Refer to Scanpy
# for correct getnnz calculation
Expand Down Expand Up @@ -561,7 +543,6 @@ def cosg(
rank_stats = pd.DataFrame(columns=idx)
rank_stats[group_i, 'names'] = adata.var_names[global_indices]
rank_stats[group_i, 'scores'] = scores[global_indices]
<<<<<<< HEAD

if calculate_logfoldchanges:
group_index=np.where(anndata_obj.groups_order==group_i)[0][0]
Expand Down Expand Up @@ -592,28 +573,15 @@ def cosg(
'names': 'O',
'scores': 'float32',
}
=======

order_i=order_i+1

## Refer to scanpy
dtypes = {
'names': 'O',
'scores': 'float32',
}
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362
###
rank_stats.columns = rank_stats.columns.swaplevel()
for col in rank_stats.columns.levels[0]:
adata.uns[key_added][col]=rank_stats[col].to_records(
index=False, column_dtypes=dtypes[col]
)

<<<<<<< HEAD


=======
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362
print('**finished identifying marker genes by COSG**')

### Return the result
Expand Down
4 changes: 0 additions & 4 deletions cosg.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Author: Min Dai
Author-email: [email protected]
License: BSD 3-Clause License
Download-URL: https://github.com/genecell/COSG
<<<<<<< HEAD
Description: |Stars| |PyPI| |Docs|

.. |Stars| image:: https://img.shields.io/github/stars/genecell/COSG?logo=GitHub&color=yellow
Expand All @@ -18,9 +17,6 @@ Description: |Stars| |PyPI| |Docs|
:target: https://cosg.readthedocs.io

Accurate and fast cell marker gene identification with COSG
=======
Description: Accurate and fast cell marker gene identification with COSG
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362
=======================================================================================================

Overview
Expand Down
32 changes: 0 additions & 32 deletions cosg/cosg.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
from typing import Iterable, Union, Optional


<<<<<<< HEAD

=======
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362
### Refer to: https://github.com/theislab/scanpy/blob/5533b644e796379fd146bf8e659fd49f92f718cd/scanpy/_compat.py
try:
from typing import Literal
Expand All @@ -27,17 +24,13 @@ def __getitem__(cls, values):
class Literal(metaclass=LiteralMeta):
pass

<<<<<<< HEAD
### Refer to Scanpy
=======
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362
def _select_top_n(scores, n_top):
reference_indices = np.arange(scores.shape[0], dtype=int)
partition = np.argpartition(scores, -n_top)[-n_top:]
partial_indices = np.argsort(scores[partition])[::-1]
global_indices = reference_indices[partition][partial_indices]
return global_indices
<<<<<<< HEAD


### Import from Scanpy
Expand Down Expand Up @@ -315,8 +308,6 @@ def _basic_stats(self):
# deleting the next line causes a memory leak for some reason
del X_rest

=======
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362

def cosg(
adata,
Expand All @@ -329,10 +320,7 @@ def cosg(

n_genes_user:int =50,
key_added: Optional[str] = None,
<<<<<<< HEAD
calculate_logfoldchanges: bool = True,
=======
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362
use_raw: bool = True,
layer: Optional[str] = None,
reference: str = 'rest',
Expand Down Expand Up @@ -361,11 +349,8 @@ def cosg(
The number of genes that appear in the returned tables. The default value is 50.
key_added
The key in `adata.uns` information is saved to.
<<<<<<< HEAD
calculate_logfoldchanges
Calculate logfoldchanges.
=======
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362
use_raw
Use `raw` attribute of `adata` if present.
layer
Expand Down Expand Up @@ -496,7 +481,6 @@ def cosg(
### Refer to scanpy
rank_stats=None

<<<<<<< HEAD
### Whether to calculate logfoldchanges, because this is required in scanpy 1.8
if calculate_logfoldchanges:
### Calculate basic stats
Expand All @@ -521,8 +505,6 @@ def cosg(
anndata_obj = _RankGenes(adata, groups_order2, groupby, reference, use_raw, layer, pts)
anndata_obj._basic_stats()

=======
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362

### Refer to Scanpy
# for correct getnnz calculation
Expand Down Expand Up @@ -561,7 +543,6 @@ def cosg(
rank_stats = pd.DataFrame(columns=idx)
rank_stats[group_i, 'names'] = adata.var_names[global_indices]
rank_stats[group_i, 'scores'] = scores[global_indices]
<<<<<<< HEAD

if calculate_logfoldchanges:
group_index=np.where(anndata_obj.groups_order==group_i)[0][0]
Expand Down Expand Up @@ -592,28 +573,15 @@ def cosg(
'names': 'O',
'scores': 'float32',
}
=======

order_i=order_i+1

## Refer to scanpy
dtypes = {
'names': 'O',
'scores': 'float32',
}
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362
###
rank_stats.columns = rank_stats.columns.swaplevel()
for col in rank_stats.columns.levels[0]:
adata.uns[key_added][col]=rank_stats[col].to_records(
index=False, column_dtypes=dtypes[col]
)

<<<<<<< HEAD


=======
>>>>>>> 55514a16bf1a93c065806f56b111f8a9905c7362
print('**finished identifying marker genes by COSG**')

### Return the result
Expand Down
Binary file removed dist/cosg-0.0.9-py3-none-any.whl
Binary file not shown.
Binary file removed dist/cosg-0.0.9.tar.gz
Binary file not shown.
Loading

0 comments on commit b6df4c0

Please sign in to comment.