写作训练
写作重要性(对于读者最困扰的事情,由小到大)
word choice
word location
sentence choice
sentence location
paragraph choice
paragraph location
写作常犯错误(由小到大)
- faulty comparison: 比较含糊且非具体的,比如说Our finding is similar to Frater et al.
- noun cluster:多个名词堆砌,比如说: water bath temperature variability results.
- undefined abbreviation: 非标准的缩写没有定义
- inconsistent key term: 关键词前后不一致,nematode,worm,C.elegans
- long sentence
- nominalization: use of noun instead f more activate and omre interesting werb
- redundancy: the same thing is said repeatedly in different ways, or unnecessarily long ohrases are used instead of shorter versions.(the majority of instead of most)
- faulty verb tense: 时态错误 present tense instead of past tense.
- unspecific word choice: 用词模糊 words are imprecise or unclear(The sample was incubated for several hours)
- faulty reference: 错误引用
- faulty structural element: 结构性要素缺失。 necessary component of a paper is missing, misplaced, or obscured (purpose of experimanet is not stated, data are not interpreted, or concluson is missing)
写作的要点
掌握基础的英语写作能力
始终牢记文章是给reader阅读的,才能有广泛的阅读。
Introdution 部分
- Interest your audience and provide context
目的是提供背景信息,激发阅读者的兴趣,使阅读者能够脱离之前的研究来读懂。
- Follow a funnel structure

Background
Unknown/Problem
Question/Purpose of study
Experimental approach
Potional: results/conclusion/significance
- Keep the introduction short
字数控制在250-600个字
- Provide pertinent background information, but do not review the literature
- State the unknown or problem
- state the central point (question/purpose or discovery statement precisely)
- state the experimental approach briefly
- ensure good cohesion and coherence
- signaling all the element of the introduction


result 部分
- Report your main findings as well as other important findings
- point the reader to the data shown in figures and tables.
- include control results
- Interpret your data for the readers
呈现数据,解释数据,而不是仅仅展示数据。Heart rate increased from 60 to 100 beats per minutes after digitails was added.
- Interpret your data for the readers
区分data和result,
- place statistical information with data. do not use it instead of results.
using number and frequency instead of probabilities or sensitivities. 放在table 或者figure legend或者句尾。
- place statistical information with data. do not use it instead of results.
- place results that answer the question of your paper at the beginning of the result section
- organize the results section chronologically or from most to least important
- emphasize and signal your results. subordinate secondary information
top sentence :emphasize results and then details of results
- organize your result into different segments
分为非描述性的和描述性的
非描述性的
purpose or background of expriment
exprimental approach
result
interpretation of result(对于描述性的文中则可以省略)- organize your result into different segments

例句截图
- word choise
- 选择precise and descriptive wording, keep wording simple.
- 使用did not 等中性词,而非could not, failed
- 不要使用clearly, it is clear/obvious 过于主观和傲慢
- 当不使用统计学参数时,使用markedly, substantially 代替significantly。最好用括号“量化”说明,否则适合放在discusssion。
- use past tense for your result, but plesent tense for descriptive papers.
signaling for paper
- use past tense for your result, but plesent tense for descriptive papers.
- omit peripheral information and irelevant general statements
- avoid exprimental details
- avoid general conclusions, speculations or compasions with other studies
Discussion
- state and interpret your key findings,provide the answer to the research question
- summarize and generalize
- keep in mind who your potential readsrs will be.
- Organize the Discussion in a pyramid structure :
First paragraph: Answer based on key findings
Supporting evidenceSubsequent paragraphs: Compasions/ contrast to previous studies
Limitations of your study Unexpected findings Hypotheses or modelsLast paragraph: Summary
Significance/Implication- Organize the topics according to the science or from most to least important in the middle of the discussion
- Compare and contrast your findings with those of other published results
- explain any discrepances, unexpected findings, and limitations.
- Provide generalizations where possible: tone 自信, person and voice 第一人称 we, tense注意finding 和result, continuity 连续
- Signal the elements of the discussion.
Revision
- 检查content and content location
步骤1. 罗列观点,以及观点相关的所有内容.
步骤2. 文章的逻辑是最重要的。检查先检查paper,然后是paragraphs,然后再是句子。主要根据下图,重点位置检查内容。
文章的整体结构:


- 检查每一部分,每一小部分的逻辑顺序。
回答观点是什么,论据是什么的问题
- 风格方面的revision
整体上,注重段落和section的过渡是否顺滑,
细节上,关注段落结果,句子结果和单词结构。
尽可能地去浓缩文章,去除不必要地细节以及重复句子等等。

- 在尽可能完善之后,等待几天再继续revision。书面性地给别人看,并且让别人提供纸质地反馈。

总结
python和R读取写入csv文件
python 读取csv文件
1 | import dask.dataframe |
python 写出文件
使用df2csv,需要输出基因和细胞名字以防万一,细胞名字在用R读取的时候会丢失。
1 | import numpy as np |
R 读取csv
1 | library(data.table) |
R 写出csv
1 | library(data.table) |
每日学习20200922
基因的跨物种序列比对以及进化树构建
工具:muscle,ggtree
1. 序列比对工具
Muscle:本地版和网页版都有,
ClustalW:速度较慢
MAFFT:氨基酸的多序列比对
lastZ:基因组比对,适用于染色质序列比对,对于gap友好
T-coffee:整合多种信息,比如结构和实验,功能比较强大
PHAST: 自荐
2. 准备序列
在ncbi下载数据,注意是基因组还是转录组的fastq数据。
如果要导入snapview提前查看序列及其特征,需要额外下载ncbi genebank 格式的文件。
各物种的序列将其整合到一个文件中,需要注意抬头的书写,识别的时候会根据空格进行分割,所以特别注意序列名称的特异性。
3. 过程:
- 首先,使用网页版的muscle
INPUT: 上述的fasta序列,在output format参数选择中,选择fasta格式和clustalW格式
OUTPUT:jalview launch file可以导入到ebi推荐的桌面app中查看 ,alignment格式文件另存为,简单的进化树直接生成。
- 在R中绘制进化树,与序列对齐,使用ggtree。
特别注意
muscle默认输出的ph格式是ntk格式,可以用ggtree的read.newick 读取。
fasta的抬头需要和ph文件的抬头一致。
- 首先,使用网页版的muscle
- 如果进化树的序列知显示一部分,则需要对fasta输出文件进行截取。
代码参考:
1 | library(ggtree) |
20200815 每日学习
文件格式: bigWig, bed, bigBed, bed narrowPeak
http://genome.ucsc.edu/goldenPath/help/wiggle.html
bigWig:
基因组中的深度学习
有监督的学习:使用标签化的数据进行训练,然后推断出输入特征和结果标签之间函数映射关系的机器学习方法,所谓训练就是求解模型参数。
绝大多数机器学习算法进行模型训练的方式:
- 分割数据:数据分为三个集合,分别是训练集、验证集和测试集。
- 使用训练集数据计算模型参数:初始化随机参数,随机抽取batch代入模型计算,然后和真实结果比较得到函数损失量,反向传播做梯度运算获得损失函数最小化的模型参数,然后再重复,知道损失函数收敛。
- 通过验证集调整模型的超参:超参是人为设定的外部参数,无法通过训练集进行训练,只能进行手动调整。
- 使用独立数据来综合评估最佳模型的性能。
深度学习网络:
隐藏层,将上一次的输入数据做转换,将其映射到一个可以对特征值进行线性分离的空间,然后激活函数将其非线性化,再给到后一层作为输入。当中间隐藏层>2,为深度神经网络模型。模型通过非线性的形式来描述真实世界的生物学问题,因为这些问题本身通常是线性模型无法解答的。
全连接网络层:网络中主要起分类器作用,本质就是将前面各层训练得到的特征空间线性的变换到另一个特征空间。目标预测就是前面各层结果的加权和。
深度卷积神经网络
Tissue-specific and Cell type-specific Genes
Paper 1
A benchmark of gene expression tissue-specificity metrics, 2017年发在Bioinformatics
组织特异性基因的定义
分为两个类别,一类是直接给一个总值来说明组织特异性与否:Tau, Gini, TSI, Counts and Hg
;还有一种是每一个组织一个值来说明特异性:z-score,SPM,EE,PEM
比较时候的方法
- score基本都呈现双峰分布
- 考虑在小数据集和大数据集上的情况,1000次的随机抽样
- 基因是否在不同物种中保守,计算correlation
- 利用已知的信息来进行验证,使用了GO term
- 考虑多种方法找的基因的交集。多余的基因做富集分析。
- quantile normalization和FPKM和RPKM影响不大,log的影响很大。
考虑数据的时候,需要考虑组织的数量,高或者低表达
microarray的数据对于组织特异性计算不友好:因为物种保守性不好
该文章推荐的方法:Tau

当需要在每一个组织一个socre的时候,PEM的表现良好(non-log
数据除外)
TissueEnrich:使用超几何分布来计算组织特异性基因的富集,使用HPA,ENCODE,GTEx数据来作为参照,来计算组织特异性基因,同时也可以输入自己的数据集
超几何分布:不放回的二抽样。
$P(X=k)=\frac{C_m^k*C_{N-m}^{m-k}}{C_N^m}$
每日学习20200808
Chipseq
参考:Y叔的公众号文章
https://mp.weixin.qq.com/s/tbqgCQ2hPYueloBlokqnoA
目的:学习chipseq 的基本知识,找Xbp1谱系特异性的结合位点。
简介:
实验原理:

数据处理过程

https://www.encodeproject.org/chip-seq/transcription_factor/
markdown-数学公式
${16}{8}O{2+}{2}$
$$V_{\mbox{初始}}$$
$\overbrace{a+b+c+d}^{2.0}$
$a+\underbrace{b+c}_{1.0}+d$
$\vec{x}\stackrel{\mathrm{def}}{=}{x_1,\dots,x_n}$
$\vec{x}$
$x \qquad y$
$xy$
$x \cdot y=z$
$x \div y=z$
$\frac{x+y}{y+z}$
平均数运算,符号:\overline{算式},如:$\overline{xyz}$
开二次方运算,符号:\sqrt,如:$\sqrt x$
开方运算,符号:\sqrt[开方数]{被开方数},如:$\sqrt[3]{x+y}$
对数运算,符号:\log,如:$\log(x)$
极限运算,符号:\lim,如:$\lim^{x \to \infty}_{y \to 0}{\frac{x}{y}}$
极限运算,符号:\displaystyle \lim,如:$\displaystyle \lim^{x \to \infty}_{y \to 0}{\frac{x}{y}}$
求和运算,符号:\sum,如:$\sum^{x \to \infty}_{y \to 0}{\frac{x}{y}}$
求和运算,符号:\displaystyle \sum,如:$\displaystyle \sum^{x \to \infty}_{y \to 0}{\frac{x}{y}}$
积分运算,符号:\int,如:$\int^{\infty}_{0}{xdx}$
积分运算,符号:\displaystyle \int,如:$\displaystyle \int^{\infty}_{0}{xdx}$
微分运算,符号:\partial,如:$\frac{\partial x}{\partial y}$
矩阵表示,符号:\begin{matrix} \end{matrix},如:$\left[ \begin{matrix} 1 &2 &\cdots &4 \ 5 &6 &\cdots &8\vdots &\vdots &\ddots &\vdots\ 13 &14 &\cdots &16\end{matrix} \right]$
| 大写字母 | 小写字母 | 拉丁字符 | Markdown |
|---|---|---|---|
| A | A | α | \alhpa |
| B | B | β | \beta |
| Γ | \Gamma | γ | \gamma |
| Δ | \Delta | δ | \delta |
| E | E | ϵ | \epsilon |
| Z | Z | ζ | \zeta |
| H | H | η | \eta |
| Θ | \Theta | θ | \theta |
| I | I | ι | \iota |
| K | K | κ | \kappa |
| Λ | \Lambda | λ | \lambda |
| M | M | μ | \mu |
| N | N | ν | \nu |
| Ξ | \Xi | ξ | \xi |
| O | O | ο | \omicron |
| Π | \Pi | π | \pi |
| P | P | ρ | \rho |
| Σ | \Sigma | σ | \sigma |
| T | T | τ | \tau |
| Υ | \Upsilon | υ | \upsilon |
| Φ | \Phi | ϕ | \phi |
| X | X | χ | \chi |
| Ψ | \Psi | ψ | \psi |
| Ω | \v | ω | \omega |
octave
octave
1 | #保存文件 |
每日学习
7.9 学习
每日一句: 此时不博更待何时
正文
马尔可夫链,随机动力学建模
隐马尔可夫链
参考网址
- 回顾了马尔可夫链的发展过程。生物过程参照HMM,另外GibbsNet和对抗训练方法来学习转移算子以及MEMM的三种方法特别值得我继续学习,看能否适用到生物网络学习中。
https://www.jiqizhixin.com/graph/technologies/fdebe132-cd51-43ba-8bda-a42abc478cbb
不同时刻的随机变量可连续可离散,具有连续或者离散的状态空间。
马尔可夫属性:给定当前状态和过去状态的流程,未来状态的条件分布只依赖于当前状态,而完全不依赖于过去状态(无记忆属性)。具有马尔可夫属性的随机过程成为马尔可夫过程。
$P(future| present,past)=P(future|present,markov property)$
马尔可夫链:马尔可夫过程与离散时间和离散状态空间。
$P(X_{n+1}=s_{n+1}| X_n=s_n,X_{n-1}=s_{n-1},X_{n-2}=s_{n-2},…)=p(X_{n+1}=s_{n+1}|X_n=s_n )$
可还原性,周期性,短暂性,复发性
静态分布,限制行为,遍历性
初始概率分布上没有假设,无论初始假设如何设置,链的概率分布都会被限制到平稳分布
在极限情况下,轨迹的早期行为可以忽略不计,只有长期静止行为在计算均值时才真正重要。
当且仅当所有的状态都是正向重复时,不可简化的马尔可夫链具有静态概率分布,收敛到静止分布,忽略早期行为。
如果链式循环正和非周期性的,污染初始概率是多少,当时间步长变为无穷大时,链的概率分布会被限制,改链被认为具有限制分布,而不是静态分布
初始概率分布没有假设,污染初始设置如何,链的概率分布都会被限制到平稳分布
网络与矩阵的对应关系,具有方向性的启示


隐马尔可夫模型(HMM)
HMM: 用来描述一个含有隐含未知参数的马尔可夫过程。
GibbsNet:通过匹配模型期望的联合分布和数据驱动的联合分布直接定义和学习转换算子,然后使用转换算子训练图模型,成功将马尔可夫链与神经网络结合起来。
对抗方法训练转移子:Jiaming Song, Shengjia Zhao和Stefano Ermon研究了生成对抗的训练方法来对马尔可夫链(Markov chain)的转移算子(transition operator)进行学习,目的是将其静态分布(stationary distribution)和目标数据分布相匹配。他们提出了一种新型的训练流程,以避免从静态分布中直接采样,但是仍然有能力逐渐达到目标分布。此模型可以从随机噪声开始,是无似然性的,并且能够在单步运行期间生成多个不同的样本。初步试验结果显示,当它临近其静态时,马尔可夫链可以生成高质量样本,即使是对于传统生成对抗网络相关理念中的较小结构亦是如此。
MEMM: 最大熵隐马尔科夫模型(MEMM)可以整个观察序列,不仅和单个词相关,而且与观察序列的长度、单词的上下文等有关。
20200716
每日一句:坚定自己的选择
Characterization of cell fate probabilities in single-cell data with Palantir
code ocean: https://codeocean.com/capsule/2535144/tree/v1
利用马尔可夫模型对细胞类型的分化建模
假设
- 1.伪时间推测算法中,假定细胞从一个较少分化状态到完全分化状态是单向的。
- 2.节点到邻近节点的过程与历史无关,即分化到下一个状态与之前的状态无关。
具体的模型
- 首先使用diffusion maps来构建nearest-neighbor graph。使用多个compents
- 从用户定义的起始细胞开始,计算拟时间,即与起始细胞的最短距离
- 利用neighbor graph and pseudo-time来构建一个markov chain来模拟分化作为随机过程,拟时间作为方向,对于每条有向边,我们都指定一步到达相邻单元的转移概率。到达较远单元的概率要经过多步计算,如果有多条路径连接它们,则概率会很高——也就是说,观察到的中间单元状态密度很高
- 马尔可夫链也用于从数据中推断终端状态。Palantir将终端状态定义为边界单元(扩散分量的极值),它们是平稳分布中的异常值,即随机游动收敛到的状态.一旦确定了终端态,我们就把它们转换成没有传出边的吸收态。在吸收马尔可夫链中,任意状态的随机游走会一直持续下去,直到到达一个终端吸收状态。对于每个细胞,Palantir然后整合所有可能的随机游走从细胞到每个可能的终端状态,以产生一个分支概率的向量.
- 根据上述定义的轨迹,利用一个广义可加模型来计算基因的表达趋势。
模型的二次理解
参数:
- k: number of neighbors of knn
- waypoints: 抽样的个数
- number of diffusion components.
具体代码解析
init.py
依赖包的载入
1 | from . import core |
core.py
run_palantir
_max_min_sampling
_compute_pseudotime
identify_terminal_states
_construct_markov_chain
_terminal_states_from_markov_chain
_differentiation_entropy
_shortest_path_helper
_connect_graph
io.py
_clean_up
from_csv
from_mtx
from_10x
from_10x_HDF5
from_fcs
plot.py
class FigureGrid
FigureGrid
density_2d
plot_molecules_per_cell_and_gene
plot_cell_clusters
plot_tsne
highlight_cells_on_tsne
plot_tsne_by_cell_sizes
plot_gene_expression
plot_diffusion_components
plot_palantir_results
plot_terminal_state_probs
plot_gene_trends
plot_gene_trend_heatmaps
plot_gene_trend_clusters
preprocess.py
filter_counts_data
normalize_counts: 使用median normalization的方法
log_transform:log2(data + pseudo_count)
persults.py
class PResults
compute_gene_trends
_gam_fit_predict
cluster_gene_trends
utils.py
run_pca
run_diffusion_maps
run_magic_imputation
determine_multiscale_space
run_tsne
determine_cell_clusters
version.py
###############################################################