Skip to content

Commit 887729d

Browse files
authored
Merge pull request #375 from broadinstitute/development
Release 1.38.0
2 parents 6ed571b + 704fa3f commit 887729d

File tree

13 files changed

+456
-251
lines changed

13 files changed

+456
-251
lines changed

.github/workflows/minify_ontologies.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ name: Minify ontologies
33
on:
44
pull_request:
55
types: [opened] # Only trigger on PR "opened" event
6-
# push: # Uncomment, update branches to develop / debug
7-
# branches:
8-
# jlc_show_gene_name
6+
# push: # Uncomment, update branches to develop / debug
7+
# branches:
8+
# jlc_show_de_pairwise
99

1010
jobs:
1111
build:

ingest/anndata_.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import scipy
77
from scipy.io.mmio import MMFile
88

9+
910
# scipy.io.mmwrite uses scientific notation by default
1011
# https://stackoverflow.com/questions/64748513
1112
class MMFileFixedFormat(MMFile):
@@ -72,7 +73,7 @@ def create_cell_data_arrays(self):
7273
linear_data_id=self.study_file_id,
7374
cluster_name=raw_filename,
7475
study_file_id=self.study_file_id,
75-
study_id=self.study_id
76+
study_id=self.study_id,
7677
):
7778
data_arrays.append(data_array)
7879

ingest/cell_metadata.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
PREREQUISITES
88
Must have python 3.6 or higher.
99
"""
10+
1011
import collections
1112
import ntpath
1213
from collections import defaultdict, OrderedDict
@@ -115,6 +116,7 @@ def validate_header_for_coordinate_values(self):
115116
"error", msg, "format:cap:metadata-no-coordinates"
116117
)
117118
return False
119+
118120
@staticmethod
119121
def make_multiindex_name(modality):
120122
"""From modality, generate column name in multi-index format"""
@@ -127,7 +129,9 @@ def create_boolean_modality_metadatum(df, modality):
127129
"""Translate presence of single modality to boolean for BigQuery"""
128130
# check for empty cells (aka. nan) or empty strings
129131
modality_multiindex = CellMetadata.make_multiindex_name(modality)
130-
no_modality_info = df[modality_multiindex].isna() | df[modality_multiindex].str.len().eq(0)
132+
no_modality_info = df[modality_multiindex].isna() | df[
133+
modality_multiindex
134+
].str.len().eq(0)
131135
bool_name = modality + "_bool"
132136
bool_multiindex = CellMetadata.make_multiindex_name(bool_name)
133137
# store inverse of no_modality_info (ie. True = has modality info)
@@ -145,12 +149,12 @@ def hide_modality_metadatum(self):
145149
m_to_rename[bool_name] = has_m
146150
self.modality_urls = self.file.filter(m_to_hide, axis=1)
147151
self.file.drop(m_to_hide, axis=1, inplace=True)
148-
self.file.rename(columns= m_to_rename, inplace=True)
152+
self.file.rename(columns=m_to_rename, inplace=True)
149153
return
150154

151155
def booleanize_modality_metadata(self):
152156
"""Translate presence of modality data to boolean for BigQuery
153-
If no modality data, self.files is unchanged
157+
If no modality data, self.files is unchanged
154158
"""
155159
if self.modalities is not None:
156160
df = copy.deepcopy(self.file)

ingest/cli_parser.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ def create_parser():
274274
help="Indicates that differential expression analysis should be invoked",
275275
)
276276

277+
parser_differential_expression.add_argument(
278+
"--de-type",
279+
default="rest",
280+
choices=['rest', 'pairwise'],
281+
help="Accepted values: 'pairwise' or 'rest' (default)",
282+
)
283+
277284
parser_differential_expression.add_argument(
278285
"--study-accession",
279286
required=True,
@@ -336,6 +343,17 @@ def create_parser():
336343
"--gene-file", help="Path to .genes.tsv file"
337344
)
338345

346+
# For pairwise analyses
347+
parser_differential_expression.add_argument(
348+
"--group1",
349+
help="1st annotation label to use for pairwise DE analysis",
350+
)
351+
352+
parser_differential_expression.add_argument(
353+
"--group2",
354+
help="2nd annotation label to use for pairwise DE analysis",
355+
)
356+
339357
parser_ingest_differential_expression = subparsers.add_parser(
340358
"ingest_differential_expression",
341359
help="Indicates author differential expression analysis processing",
@@ -377,40 +395,38 @@ def create_parser():
377395
parser_ingest_differential_expression.add_argument(
378396
"--differential-expression-file",
379397
required=True,
380-
help="Path to DE file uploaded by author."
398+
help="Path to DE file uploaded by author.",
381399
)
382400

383401
parser_ingest_differential_expression.add_argument(
384402
"--gene-header",
385403
required=True,
386-
help="Header used for gene names / symbols in DE file"
404+
help="Header used for gene names / symbols in DE file",
387405
)
388406

389407
parser_ingest_differential_expression.add_argument(
390-
"--group-header",
391-
required=True,
392-
help="Header used for group in DE file"
408+
"--group-header", required=True, help="Header used for group in DE file"
393409
)
394410

395411
parser_ingest_differential_expression.add_argument(
396412
"--comparison-group-header",
397413
required=False,
398414
help=(
399-
"Header used for comparison group in DE file. " +
400-
"For pairwise comparisons. Can omit if DE file is in one-vs-rest-only format."
401-
)
415+
"Header used for comparison group in DE file. "
416+
+ "For pairwise comparisons. Can omit if DE file is in one-vs-rest-only format."
417+
),
402418
)
403419

404420
parser_ingest_differential_expression.add_argument(
405421
"--size-metric",
406422
required=True,
407-
help='Header used as size metric in DE file, e.g. "logfoldchanges", "avg_log2FC", etc.'
423+
help='Header used as size metric in DE file, e.g. "logfoldchanges", "avg_log2FC", etc.',
408424
)
409425

410426
parser_ingest_differential_expression.add_argument(
411427
"--significance-metric",
412428
required=True,
413-
help='Header used as significance metric in DE file, e.g. "pvals_adj", "p_val_adj", etc.'
429+
help='Header used as significance metric in DE file, e.g. "pvals_adj", "p_val_adj", etc.',
414430
)
415431

416432
# AnnData subparsers
@@ -493,7 +509,7 @@ def create_parser():
493509
parser_rank_genes.add_argument(
494510
'--publication',
495511
help="URL of the study's publicly-accessible research article, or GS URL or local path to publication text file",
496-
required=True
512+
required=True,
497513
)
498514

499515
return parser

ingest/clusters.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,11 @@ def transform(self):
136136
{
137137
"name": annot_name,
138138
"type": annot_type,
139-
"values": self.file[annot_headers].unique().tolist()
140-
if annot_type == "group"
141-
else [],
139+
"values": (
140+
self.file[annot_headers].unique().tolist()
141+
if annot_type == "group"
142+
else []
143+
),
142144
}
143145
)
144146
Annotations.dev_logger.info(f"Creating model for {self.study_id}")
@@ -148,9 +150,11 @@ def transform(self):
148150
cell_annotations=cell_annotations,
149151
study_file_id=self.study_file_id,
150152
study_id=self.study_id,
151-
domain_ranges=DomainRanges(**self.domain_ranges)
152-
if self.domain_ranges is not None
153-
else None,
153+
domain_ranges=(
154+
DomainRanges(**self.domain_ranges)
155+
if self.domain_ranges is not None
156+
else None
157+
),
154158
)
155159

156160
def get_data_array_annot(self, linear_data_id):

0 commit comments

Comments
 (0)