Skip to content
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

Enable FastMNN #246

Merged
merged 10 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,18 @@ Object {
"dataIntegration": Object {
"method": "seuratv4",
"methodSettings": Object {
"fastmnn": Object {
"normalization": "logNormalize",
"numGenes": 2000,
},
"seuratv4": Object {
"normalization": "logNormalize",
"numGenes": 2000,
},
"unisample": Object {
"normalization": "logNormalize",
"numGenes": 2000,
},
},
},
"dimensionalityReduction": Object {
Expand Down
8 changes: 8 additions & 0 deletions src/__test__/test-utils/experimentSettings.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ const testableProcessingConfig = {
numGenes: 2000,
normalization: 'logNormalize',
},
fastmnn: {
numGenes: 2000,
normalization: 'logNormalize',
},
unisample: {
numGenes: 2000,
normalization: 'logNormalize',
},
},
},
dimensionalityReduction: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
import _ from 'lodash';

import SeuratV4Options from './SeuratV4Options';
import FastMNNOptions from './FastMNNOptions';
import UnisampleOptions from './UnisampleOptions';

import { updateProcessingSettings } from '../../../redux/actions/experimentSettings';
import generateDataProcessingPlotUuid from '../../../utils/generateDataProcessingPlotUuid';
Expand Down Expand Up @@ -52,6 +54,16 @@ const CalculationConfig = (props) => {
text: 'Seurat v4',
disabled: false,
},
{
value: 'fastmnn',
text: 'Fast MNN',
disabled: false,
},
{
value: 'unisample',
text: 'No integration',
disabled: false,
},
{
value: 'seuratv3',
text: 'Seurat v3',
Expand All @@ -72,11 +84,6 @@ const CalculationConfig = (props) => {
text: 'Liger',
disabled: true,
},
{
value: 'fastMNN',
text: 'Fast MNN',
disabled: true,
},
];

const [numPCs, setNumPCs] = useState(dimensionalityReduction.numPCs);
Expand Down Expand Up @@ -105,6 +112,22 @@ const CalculationConfig = (props) => {
disabled={disabled}
/>
),
fastmnn: () => (
<FastMNNOptions
config={dataIntegration.methodSettings.fastmnn}
onUpdate={updateSettings}
onChange={() => setChangesOutstanding(true)}
disabled={disabled}
/>
),
unisample: () => (
<UnisampleOptions
config={dataIntegration.methodSettings.unisample}
onUpdate={updateSettings}
onChange={() => setChangesOutstanding(true)}
disabled={disabled}
/>
),
};

const roundedVariationExplained = () => {
Expand Down
129 changes: 129 additions & 0 deletions src/components/data-processing/DataIntegration/FastMNNOptions.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { Form, InputNumber, Select, Tooltip, Typography } from 'antd';

import {
QuestionCircleOutlined,
} from '@ant-design/icons';

const { Option } = Select;
const { Text } = Typography;

const FastMNNOptions = (props) => {
ivababukova marked this conversation as resolved.
Show resolved Hide resolved
const {
config, onUpdate, onChange, disabled,
} = props;

const [numGenes, setNumGenes] = useState(config.numGenes);

return (
<>
<Form.Item label='# of HGV genes'>
<InputNumber
value={numGenes}
step={100}
min={1}
onChange={(value) => {
onChange();
setNumGenes(value);
}}
onPressEnter={(e) => e.preventDefault()}
onStep={(value) => onUpdate({
dataIntegration: {
methodSettings: {
fastmnn: {
numGenes: value,
},
},
},
})}
onBlur={(e) => onUpdate({
dataIntegration: {
methodSettings: {
fastmnn: {
numGenes: parseInt(e.target.value, 0),
},
},
},
})}
disabled={disabled}
/>
{' '}
<Tooltip overlay={(
<span>
Number of genes to mark as top highly variable genes (HGV).
Integration as well as PCA is based on a sensible selection of HGV.
Here, this number selects the top variable genes based on the "vst" method.
The default 2000 has been found to be a sensible for many cases.
Further info can be found
<a
href='https://satijalab.org/seurat/articles/integration_introduction.html'
target='_blank'
rel='noreferrer'
>
{' '}
<code>here</code>
</a>
</span>
)}
>
<QuestionCircleOutlined />
</Tooltip>
</Form.Item>
<Form.Item label={(
<span>
Normalization&nbsp;
<Tooltip overlay={(
<span>
Normalization aims to remove technical factors including sequencing depth.
There are several methods to achive normalization.
"sctransform" claims to recover sharper biological distinction compared to log-normalization.
Normalization is applied to each sample before integration.
Further info can be found
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a nice message, but it will be better if you are more explicit and say Cellscope uses "sctransform".' after sentence There are several methods to achive normalization.`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also a typo in achive -- it is achieve and there should be a comma just after factors on the first line (I think :D ). It would read better if you rephrased the first sentence to Normalization aims to remove technical factors, like sequencing depth for example.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it is worth to point out that I personally have no idea what technical factors mean. That can just as well be because of my lack of biology/bioinformatics background. I am noting it, because if biologists might not know this, we will need to rephrase it. @vickymorrison any thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @ivababukova! For this PR I looked at what was already in place in SeuratV4Options to create the counterpart to FastMNN and Unisample. In the new commit Martin has done a great job of refactoring. Regarding technical errors, I guess it refers to possible biases that occur when sequencing or in the lab in the sample preparation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the first sentence, how about: "Normalization aims to remove technical variation that is not biologically relevant, e.g. sequencing depth." ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that we could add as covariates for the normalization the mt-content, so I guess we should not especify biologically relevant. For the current version we cannot add covariates but I think that we will support it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would argue that 'not biologically relevant' still stands - if the user chooses to exclude specific gene categories that is because they believe those genes are not biologically relevant to the question they are trying to answer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense! I'll change!

<a
href='https://satijalab.org/seurat/articles/sctransform_vignette.html'
target='_blank'
rel='noreferrer'
>
{' '}
<code>here</code>
</a>
</span>
)}
>
<QuestionCircleOutlined />
</Tooltip>
</span>
)}
>
<Select
value={config.normalization}
onChange={(val) => onUpdate({
dataIntegration: {
methodSettings: {
fastmnn: { normalization: val },
},
},
})}
disabled={disabled}
>
<Option value='logNormalize'>LogNormalize</Option>
<Option value='scTransform'>SCTransform</Option>
</Select>

</Form.Item>
</>
);
};

FastMNNOptions.propTypes = {
config: PropTypes.object.isRequired,
onUpdate: PropTypes.func.isRequired,
onChange: PropTypes.func,
};

FastMNNOptions.defaultProps = {
onChange: null,
};

export default FastMNNOptions;
129 changes: 129 additions & 0 deletions src/components/data-processing/DataIntegration/UnisampleOptions.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { Form, InputNumber, Select, Tooltip, Typography } from 'antd';

import {
QuestionCircleOutlined,
} from '@ant-design/icons';

const { Option } = Select;
const { Text } = Typography;

const UnisampleOptions = (props) => {
const {
config, onUpdate, onChange, disabled,
} = props;

const [numGenes, setNumGenes] = useState(config.numGenes);

return (
<>
<Form.Item label='# of HGV genes'>
<InputNumber
value={numGenes}
step={100}
min={1}
onChange={(value) => {
onChange();
setNumGenes(value);
}}
onPressEnter={(e) => e.preventDefault()}
onStep={(value) => onUpdate({
dataIntegration: {
methodSettings: {
unisample: {
numGenes: value,
},
},
},
})}
onBlur={(e) => onUpdate({
dataIntegration: {
methodSettings: {
unisample: {
numGenes: parseInt(e.target.value, 0),
},
},
},
})}
disabled={disabled}
/>
{' '}
<Tooltip overlay={(
<span>
Number of genes to mark as top highly variable genes (HGV).
Integration as well as PCA is based on a sensible selection of HGV.
Here, this number selects the top variable genes based on the "vst" method.
The default 2000 has been found to be a sensible for many cases.
Further info can be found
<a
href='https://satijalab.org/seurat/articles/integration_introduction.html'
target='_blank'
rel='noreferrer'
>
{' '}
<code>here</code>
</a>
</span>
)}
>
<QuestionCircleOutlined />
</Tooltip>
</Form.Item>
<Form.Item label={(
<span>
Normalization&nbsp;
<Tooltip overlay={(
<span>
Normalization aims to remove technical factors including sequencing depth.
There are several methods to achive normalization.
"sctransform" claims to recover sharper biological distinction compared to log-normalization.
Normalization is applied to each sample before integration.
Further info can be found
<a
href='https://satijalab.org/seurat/articles/sctransform_vignette.html'
target='_blank'
rel='noreferrer'
>
{' '}
<code>here</code>
</a>
</span>
)}
>
<QuestionCircleOutlined />
</Tooltip>
</span>
)}
>
<Select
value={config.normalization}
onChange={(val) => onUpdate({
dataIntegration: {
methodSettings: {
unisample: { normalization: val },
},
},
})}
disabled={disabled}
>
<Option value='logNormalize'>LogNormalize</Option>
<Option value='scTransform'>SCTransform</Option>
</Select>

</Form.Item>
</>
);
};

UnisampleOptions.propTypes = {
config: PropTypes.object.isRequired,
onUpdate: PropTypes.func.isRequired,
onChange: PropTypes.func,
};

UnisampleOptions.defaultProps = {
onChange: null,
};

export default UnisampleOptions;