<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title></title>
    <description>为学日益，为道日损。</description>
    <link>https://liuxm0239.github.io/</link>
    <atom:link href="https://liuxm0239.github.io/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Thu, 29 Oct 2026 16:08:48 +0000</pubDate>
    <lastBuildDate>Thu, 29 Oct 2026 16:08:48 +0000</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
    
      <item>
        <title>游民一周年</title>
        <description>&lt;ul&gt;
  &lt;li&gt;content&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;p&gt;游民一周年&lt;/p&gt;

&lt;h1 id=&quot;缘启&quot;&gt;缘启&lt;/h1&gt;

&lt;p&gt;今天是我离开职场一周年的日子了，回想起来也是感慨万分。这一整年，说不上惊心动魄，然而个中曲折却也是蜿蜒崎岖，跌宕起伏。
我于2025 年 9 月  26 日 从公司离职。去职后以公司未足额支付未休年假工资为由，彻底切断了与公司再次联系的可能，落得一身轻松。之所以离开，一方面是实在看不惯公司的一些行为，对行业前景的预期也偏悲观；另一方面是之前理财有所收获，想以此为基点打造被动收入来源。最重要的是加上家人的支持，于是自绝于职场，从此开始了游民生活。&lt;/p&gt;

&lt;h1 id=&quot;回顾&quot;&gt;回顾&lt;/h1&gt;
&lt;p&gt;过去一年核心的任务当然是金融交易分析，但前进途中多生枝杈。&lt;/p&gt;

&lt;p&gt;第一个就是这一年公务员考试年龄限制突然放宽到 38 周岁以下，于是就有了一次也是最后一次冲击的机会，就花精力去学习了一段时间。内心摇摆，岗位竞争激烈，遇上些困难就退缩了，于是草草收场。实在是惭愧。&lt;/p&gt;

&lt;p&gt;再一个是代账公司的尝试，那时家里人刚好接触到一些海南的代账相关业务，在那边也有一些资源可以运作。虽然相关业务我完全不懂，但可以作为执行人试着运营一下。也曾组织了几次会议讨论，对财税报账有了一点点了解。但是涉及到实际业务落地的时候，才发现看起来简单的事情，没有相关的基础业务的积累，贸然进场是决计难成的，被业内人士教育一番，戛然而止。&lt;/p&gt;

&lt;p&gt;然后是 CPA（注册会计师）考试，这个是在学习交易分析中发现一定的的财务分析能力是有益的。于是开始啃会计学原理，然后再接触到初级会计师、注册会计师相关考试的内容。但是工作这么久，一直明白证书只是敲门砖，跟实际应用有不小的距离，也没有一直下定决心去考，只是当做一个支线任务对待了。好在是会计学原理，财务报表分析，公司估值这些都在慢慢积累。&lt;/p&gt;

&lt;p&gt;当然，最核心的是金融交易分析了。2021 年 12 月开始进入股票市场，因为有全职工作花在这上面的时间非常少，看得少操作也少，到 2025 年四年间总共操作过的股票不过七八只。策略无非是低买高卖，收益率倒是还可以，颇让人意外。转折点出现在 2025 年 4 月，清明节前夕特朗普发动全球关税战，股市一片哀鸿，当时股市连跌。但我觉得是个机会，在连跌三四天之后，先后买入了两只之前一直看好，感觉跌的差不多了的股票，由此收获颇丰，自己对交易分析也愈加感兴趣了。再加上公司环境不好，行业前景看淡，累加上整体大环境低迷的影响，感觉打工这条路难行，需要稳定的被动收入的支持。&lt;/p&gt;

&lt;p&gt;真的从职场里出来之后，心态的变化是缓慢而又深刻的，不像离职那样咔哒一下就彻底不一样了。对我来说这个变化远比技术分析、基本面分析来的重要的多。我学习金融交易分析的过程也是如此，从心理分析开始的。真正意义上的入门教材是马克·道格拉斯的《交易心理分析》，最开始是上下班路上听有声书，之后买了实体书反复看过几遍，总结其核心思想就是持续的交易成功人士依靠的是其思想，并不决定于市场、技术分析、基本面分析等等。这个结论看起来简单而又玄乎，但其中深意非亲自下场走一圈所不能体会。之后一年所学的种种，都没跳出这样一个结论。&lt;/p&gt;

&lt;p&gt;大概捋一下我的学习路线：&lt;/p&gt;

&lt;p&gt;最开始是想着尽快建立交易系统，由于之前了解的少，操作的也少，对于交易系统这种听起来高大上的东西有种仰望的感觉。就在网上搜乱七八糟的教程，希望能尽快捋出个头绪。幸运的是没过多久就找到了“云聪金融分析“这个主播的教程，我感觉自己因此少走了弯路。&lt;/p&gt;

&lt;p&gt;所以最先学习的就是技术面分析，由于之前没怎么接触过的，而且技术指标这些东西是理工科背景的是喜闻乐见的。于是跟着云聪老师的频道“云聪金融分析“开始学习。云聪老师他个人性格热情爱学习爱分享，工作和交易经验非常深厚，实战结果优秀，更难能可贵的是把他个人基本面分析技术、交易心理分析、哲学学习和成长的完整过程都无私分享了出来，偶尔还会有免费的实盘直播，实在是让人受益匪浅。这个过程中，我对基本面分析的各个领域，包括道氏理论（趋势、形态与突破）、威科夫交易法（量价分析）、K 线组合+价格行为学、波浪理论、江恩理论、亚当理论、海龟交易法（量化分析）等等都有了大概的认识。更难能可贵的是他把自己学习和认知改变的过程都完整分享了出来，真是开心见诚，无所隐伏。他录制的课程数量繁多，但按照他梳理出来的框架依次学习也并不杂乱。有些视频我看了两遍以上，随着自身的积累增长，每次观看都有不同的感悟。等大概学完就明白了自己的性格跟云聪老师迥异，不适合短线操作的交易方案，后面也就转到价值投资理论上去了。&lt;/p&gt;

&lt;p&gt;然后就是开始研究价值投资了。平时零零碎碎也听过巴菲特、查理·芒格的一些理论方法，但真正让我深入的是李录在北大价值投资课上的几次演讲以及他的《文明、现代化、价值投资与中国》。由此也接触到了北京大学的价值投资课，跟着网上的公开资料，开始系统的学习价值投资。也是因为这门课程接触到了秉承价值投资理念的各家各派，包括格雷厄姆、巴菲特、查理·芒格、李录、段永平、归江、但斌、唐朝、普拉克·普拉萨德（印度，那烂陀资本）等，在这个过程中也知道了价值投资者也是百花齐放，各放异彩，最终最终需要做的也是需要融汇贯通形成自己的投资体系，目前也还在学习当中。&lt;/p&gt;

&lt;p&gt;回看过去一年的收益，并没有比之前“散养“的时候高。在跟着云聪老师学习的时候，也跟着做过一些短线操作、龙头战法等等之类的交易方法尝试，都不是很成功。目前又回归到少看少操作的状态上，难以戒掉的是总是忍不住盯盘，这个其实意义不大副作用却不小，希望能早日摆脱。&lt;/p&gt;

&lt;p&gt;相比较来说更大的收获是能静下心来读书了，这一年读完的书恐怕比之前十年读的还要多，于自己的心灵疗愈良多。&lt;/p&gt;

&lt;p&gt;书单&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;小狗钱钱&lt;/li&gt;
  &lt;li&gt;经济学原理 曼昆&lt;/li&gt;
  &lt;li&gt;潜规则 吴思&lt;/li&gt;
  &lt;li&gt;中国历代政治得失 钱穆&lt;/li&gt;
  &lt;li&gt;原则 瑞·达利欧&lt;/li&gt;
  &lt;li&gt;改变：问题形成与解决之道&lt;/li&gt;
  &lt;li&gt;邓小平时代&lt;/li&gt;
  &lt;li&gt;李光耀观天下&lt;/li&gt;
  &lt;li&gt;主角 陈彦&lt;/li&gt;
  &lt;li&gt;文明、现代化、价值投资与中国 李录&lt;/li&gt;
  &lt;li&gt;聪明的投资者 本杰明·格雷厄姆&lt;/li&gt;
  &lt;li&gt;郭鹤年自传&lt;/li&gt;
  &lt;li&gt;金钱风云 单伟建&lt;/li&gt;
  &lt;li&gt;价值投资实战手册 唐朝&lt;/li&gt;
  &lt;li&gt;手把手教你读财报 唐朝&lt;/li&gt;
  &lt;li&gt;我从达尔文那里学到的投资知识&lt;/li&gt;
  &lt;li&gt;从优秀到卓越 吉姆·柯林斯&lt;/li&gt;
  &lt;li&gt;寻找家园 高尔泰&lt;/li&gt;
  &lt;li&gt;社会性征服地球&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Wed, 30 Sep 2026 03:16:52 +0000</pubDate>
        <link>https://liuxm0239.github.io/2026/09/30/one-year/</link>
        <guid isPermaLink="true">https://liuxm0239.github.io/2026/09/30/one-year/</guid>
        
        <category>Live</category>
        
        
        <category>life</category>
        
      </item>
    
      <item>
        <title>Snakemake</title>
        <description>&lt;ul&gt;
  &lt;li&gt;content&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;p&gt;Snakemake 搭建流程&lt;/p&gt;

&lt;h1 id=&quot;介绍&quot;&gt;介绍&lt;/h1&gt;

&lt;p&gt;对于生信分析，大部分人的第一印象就是流程化。确实，在依托于强大的计算机系统，许多常规的分析任务都可以自动化运行并进行相应的分析。例如对于测序数据来说，常见的上游分析便是数据质控、去接头、序列比对、 PCR 去重矫正、基因表达定量、突变和拷贝数分析等。这些分析步骤中，每一步都有很多不同的软件和算法，选择多样化。而对于数据分析者来说，这些上游的步骤并不是他们所关注的，他们可能更注重一些下游的个性化分析，所以前面的数据处理和分析工作完全可以让流程自动完成。
所谓流程，便是能够将分析步骤进行串联，多样本并行计算。常见的流程化一般使用 shell脚本，将所有分析任务写入到一个脚本中，这种方法扩展性较差，程序臃肿。而 Python 是一门非常灵活的语言，非常适合用来编写模块化的流程，但比较麻烦的一点是，需要自己进行一些命令的封装。幸好，已经有人帮我们做好了。&lt;/p&gt;

&lt;p&gt;Snakemake 是一种基于 Python 的工作流管理系统，能够用于创建可重复和可扩展的数据分析的工具。其编写的流程可以无缝部署到服务器、集群等环境，而无需对流程进行修改。依托于 conda 包管理系统，不需要我们手动安装依赖软件，可以做到只修改配置文件便能运行整个流程。会自动检查文件时间戳，能够从上次中断的位置继续往下跑，而不用重复执行。&lt;/p&gt;

&lt;h1 id=&quot;安装&quot;&gt;安装&lt;/h1&gt;

&lt;p&gt;安装 snakemake 最好的方式是使用包管理工作conda或mamba，mamba是 conda 的C++ 实现版，使用多线程下载缓存，更快的解决包依赖关系，极大提供包搜索速度，其使用方式与 conda 一样。&lt;/p&gt;

&lt;h2 id=&quot;安装-mamba&quot;&gt;安装 mamba&lt;/h2&gt;

&lt;p&gt;conda install -n base -c conda-forge mamba
将 snakemake 安装到虚拟环境
mamba create -c conda-forge -c bioconda -n snakemake snakemake
进入环境，查看是否安装成功
conda activate snakemake
snakemake –help&lt;/p&gt;

&lt;h1 id=&quot;定义流程&quot;&gt;定义流程&lt;/h1&gt;

&lt;p&gt;受 Make 的启发，snakemake 使用 rule 字段来定义一个从输入文件到输出文件的规则而不同规则之间的依赖关系是通过输入和输出文件名称进行匹配，隐式地进行处理。一个rule 可以看作是一个操作步骤，比如序列比对、表达定量等调用特定软件的步骤就可以定义一个 rule 来处理。&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;基本语法
snakemake 使用冒号和缩进来定义规则，并用一些关键字来进行规则声明，同时也可以兼容Python 代码。
在rule 声明的规则中，有很多关键字用于定义不同的规则和文件信息，例如&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;定义 rule一个 rule 定义了流程中的一项数据分析步骤，使用关键字 rule 声明，包括规则名称，输入文件、输出文件以及输入文件映射到输出文件的 shell 命令或一个处理脚本。例如&lt;/p&gt;

    &lt;p&gt;rule NAME:
     input: 
         “path/to/inputfile1”, 
         “path/to/inputfile2”
     output:
         [“path/to/outputfile1”, “path/to/outputfile2”]
     shell:
         “command {input} {output}”&lt;/p&gt;

    &lt;p&gt;规则的名称是可选的，可以省略，表示一个匿名规则。也可以通过设置规则的 name 属性来
 覆盖。
 其中 input 和 output 可以是元组或者列表，最后一行的 shell 表示需要执行的 shell命令，其中花括号表示引用，即使用 input 和 output 关键字中定义的值来进行字符串替换。可以使用双花括号来取消这种占位符替换，会被转换为单花括号字符。在这里输入和输出列表会被转换为空格分隔的字符串(类似于·’.join(input))。
 也可以使用字典的方式定义键值对，例如
 rule NAME:
     input:
         fastq1k= “path/to/inputfile”
         fastq2 =”path/to/other/inputfile”
     output:
         “path/to/outputfile”,
         somename =”path/to/another/outputfile”
     shell:
         “command {input.fastq1} {input.fastq2} {output[0]}’
 在花括号内使用点加属性名称或使用数组索引的方式访问
 当要同时运行多个 shell 命令或编写 Python 代码时，可以使用 run
 rule NAME: 
     input:
         “path/to/inputfile”.
         “path/to/other/inputfile”
     output:
         “path/to/outputfile”,
         somename =”path/to/another/outputfile”
     run:
         for f in input:
         with open(output[0], “w”) as out:
             out.write(…)with open(output.somename, “w”) as out.out.write(…)
         shell(‘cp {input[1]} {output.somename}’)
在 run 字段中，可以使用列表或属性获取的方式来访问input和 output 中定义的值。&lt;/p&gt;
    &lt;h3 id=&quot;通配符&quot;&gt;通配符&lt;/h3&gt;
    &lt;p&gt;有时候，我们的输入或输出文件并不是固定的名称，比如我们分析一批数据不可能只有一个样本，而且每次分析样本的名称肯定不一样，因此将输入或输出指定为一种可变的，或者可替换的字符是很有必要的，这也是 snakemake 的一个优势所在。例如下面这个例子
 rule complex_conversion:
     input:
         “input/{sample}_file”
     output:
         “output/{sample}/file.{group}.txt”
     shell:
         “somecommand -group {wildcards.group}&amp;lt;{input}&amp;gt; {output}”
在这里，我们定义了两个通配符 sample 和 group，这两个通配符相当于正则表达式中的.+，可以匹配除空字符外的任意字符串。
在 shell 字段中，可以使用wildcards 对象来访问对应的通配符，该对象是一个内置对象，所有通配符均为其属性。
但有时，通配符可能会导致歧义，例如，对于通配符{sample}.{group}.txt，从字符串A.R.1.txt 中无法确定 sample 是 A.R 还是 A。这时，我们需要添加一些约束条件，可以有三种方式来添加
       - 在通配符后面使用逗号并添加限定的正则表达式
 output:”{sample}.{group,\d+}.txt”
       - 使用 wildcard_constraints 关键字
 rule complex_conversion:
     input:
         “input/{sample}_file”
     output:
         “output/{sample}/file.{group}.txt”
     wildcard_constraints:
         group =”\d+”
     shell:
         “somecommand –group {wildcards.group} &amp;lt; {input}&amp;gt; {output}”
       - 定义全局的通配符约束
 wildcard_constraints:
     group=”\d+”&lt;/p&gt;

    &lt;p&gt;rule a:
     …
 rule b:
     …
那这些通配符的值是怎么推断出来的呢?
一种方式是在终端运行文件时指定输出文件的路径，会通过文件路径进行推断
 snakemake -s Snakefile output/A/file.Rl.txt
其中 rule 规则定义在 Snakefile 中。也可以在 rule all 中的 input 中定义
 rule all:
     input:
         “output/A/file.R1.txt”
all 这个规则名称时固定的，而且只要在 input 中定义需要执行的输出文件， snakemake会自动运行相应的规则，及其依赖的规则。也就是说如果该文件的输出需要其他规则，那些规则也会自动执行，其最终的目的就是必须获取到 input 里面定义的文件。
snakemake 默认只会执行文件中第一个 rule ，可能有些规则虽然定义了，但是没有指定输出文件，也不会被执行。可以设置在rule 中设置 default_target:True 将其标注为默认执行的规则，但我们一般还是会在input 中进行指定&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;聚合&quot;&gt;聚合&lt;/h3&gt;
&lt;p&gt;输入和输出文件可以是 Python 列表，我们可以使用列表推导式来定义输入文件。例如
    rule aggregate:
        input:
            [“{dataset}/a.txt”,format(dataset=dataset) for dataset inDATASETS]
        output:
            “aggregated.txt”&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    shell:
        ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;其中， dataset 不会被认为是通配符，而是和 Python 中的格式化字符串的占位符
snakemake 提供两种简洁的方式来实现同样的功能&lt;/p&gt;
&lt;h3 id=&quot;expand-函数&quot;&gt;expand 函数&lt;/h3&gt;
&lt;p&gt;该函数类似于 Python 字符串的 format 方法，使用关键字的方式指定需要替换的值
    rule aggregate:
        input:
            expand(“{dataset}/a.txt”, dataset=DATASETS)
        output:
            “aggregated.txt”
        shell:
            …
该函数提供的功能也比较丰富，可以同时替换多个字符串。例如
    expand([“{dataset}/a.{ext}”,”{dataset}/b.{ext}”],dataset=[‘GE0’,’KEGG’],ext=[‘txt’,’csv’])
代表的文件列表为
    [“GE0/a.txt”,”GE0/b.txt”,”KEGG/a.txt”,”KEGG/b.txt”“GE0/a.csv”，”GE0/b.csv”，”KEGG/a.csv”，”KEGG/b.csv”]
该函数默认使用 Python 中 itertools 包中的 product 函数对 dataset 和 ext 取笛卡尔积，然后将数据填充进去，我们也可以使用其他组合函数或自定义函数。例如，使用 zip函数
    expand([“{dataset}/a.{ext}”,”{dataset}/b.{ext}”],
      zip,dataset=[‘GE0’,’KEGG’],ext=[‘txt’,’csv’])
将会得到
    [“GE0/a.txt”,”GE0/b.txt”,”KEGG/a.csv”，”KEGG/b.csv”]&lt;/p&gt;
&lt;h3 id=&quot;multiext-函数&quot;&gt;multiext 函数&lt;/h3&gt;
&lt;p&gt;对于名称相同但是扩展名不同的文件列表，可以使用 multiext 函数，它是 expand 函数的变体，例如
    rule plot:
    input:
        …
    output:
        multiext(“some/plot”, “.pdf”, “.svg”, “.png”)
    shell:
        …
第一个参数定义文件名，后面的参数为不同的文件后缀。上面的代码相当于
    expand(“some/plot.{ext}”, ext=[“.pdf”, “.svg”, “.png”])&lt;/p&gt;

&lt;h3 id=&quot;线程&quot;&gt;线程&lt;/h3&gt;
&lt;p&gt;线程数通过 threads 关键字指定，指定程序使用的最大线程数，该值不会大于总的可用线程
    rule NAME:
        input:
            “path/to/inputfile”，
            “path/to/other/inputfile”
        output:
            “path/to/outputfile”, 
            “path/to/another/outputfile”
        threads: 8
        shell:
            “somecommand –threads {threads} {input} {output}”&lt;/p&gt;
&lt;h3 id=&quot;资源&quot;&gt;资源&lt;/h3&gt;
&lt;p&gt;可以使用 resources 关键字来指定程序使用的资源，例如内存资源、磁盘空间、gpu 等。调度程序会确保运行任务不会超出给定资源数，注意资源数是被指定为每个作业的总数，而不是每个线程的资源数。
    rule a:
        input:
        output: …
        resources:
            mem_mb=100,
            nvidia_gpu=1
        shell:
            …&lt;/p&gt;
&lt;h3 id=&quot;消息&quot;&gt;消息&lt;/h3&gt;

&lt;p&gt;snakemake 运行流程时，控制台会输出每个规则的简短摘要信息，我们可以使用 message参数来为每个规则指定运行时的输出信息
    ruLe NAME:
        input:
            “path/to/inputfile”,
            “path/to/other/inputfile”
        output: 
            “path/to/outputfile”, 
            “path/to/another/outputfile”
        threads:8
        message: 
            “Executing somecommand with {threads} threads on thefollowing files {input}.”
        shell:
            “somecommand –threads {threads} {input} {output}”
在 message 中也可以像 shell 一样，使用 wildcards 对象访问通配符&lt;/p&gt;
&lt;h3 id=&quot;优先级&quot;&gt;优先级&lt;/h3&gt;
&lt;p&gt;可以使用 priority 关键字为规则添加数字优先级，默认情况下，每个规则的优先级都为
8，数值越大优先级越高
    rule :
        input: …
        output: …
        priority: 50
        shell: …&lt;/p&gt;
&lt;h3 id=&quot;日志&quot;&gt;日志&lt;/h3&gt;
&lt;p&gt;每个规则也可以使用 log 关键字定义日志文件
    rule abc:
        input: “input.txt”
        output: “output.txt”
        log: “logs/abc.log”
        shell:”somecommand -log {log} {input} {output}”
其与 output 类似，日志文件可以使用通配符，也支持文件列表形式。
    rule abc:
        input: “input.txt”
        output: “output.txt”
        log:log1=”logs/{sample}/abc.log”,log2=”logs/xyz.log’
        shell:”somecommand -log {log.Log1} METRICS_FILE-{log.log2} {input}{output}”
不同点在于当程序运行出错时，输出文件会被删除，而 1og 文件将会保留，有助于排查程序问题&lt;/p&gt;

&lt;h3 id=&quot;参数&quot;&gt;参数&lt;/h3&gt;
&lt;p&gt;input 和 output 都是指定文件，但是我们所使用的程序一般不仅仅只有输入和输出参数,还有其他控制参数，这些参数是无法通过这两个参数指定的。此时，可以使用 params 关键
    rule:
        input:
        params:
            prefix=”somedir/{sample}”
        output:
            “somedir/{sample}.csv’
        shell:
            “somecommand -o {params.prefix}”
参数值不仅可以是字符串，还可以使用函数获取值
    prefix=lambda wildcards, output: output[e][:-4]
函数的第一个参数必须为 wildcards，还可以接受四个参数 input、 output、threads和 resources ，这几个参数的位置可以任意顺序。如果需要将通配符作为参数传入到运行的脚本中，需要使用函数的形式，例如
    rule annotatePeaks:
        input:
            peakfile = “macs2/narrow/{sample}_peaks.narrowPeak”,gtf = config[‘data’][‘gtf’]
        output:
            expand(‘macs2/anno/.peakAnno.{ext}’, ext=[‘pdf’, ‘txt’])
        params :
            sample = lambda wildcards:{}’.format(wildcards.sample),
            output = config[‘workdir’]+”/macs2/anno/”
        script:
            ‘annoPeaks.R’
其中 script 关键字用于指定需要运行的脚本&lt;/p&gt;

&lt;h3 id=&quot;外部脚本&quot;&gt;外部脚本&lt;/h3&gt;
&lt;p&gt;规则中定义的命令，不仅可以是 shell 命令或内联的 Python 代码，也可以指定外部脚本。支持 Python、R、Julia、Rust 和 Bash 脚本，使用 script 关键字指定。
这些脚本在运行时都会传入一个 snakemake 对象(Bash 中传入的是一些关联数组，没有对象)，该对象包含属性:input、output、params、wildcards、log、 threads、resources、config。可以在脚本中进行访问
在 Python 中，使用 snakemake 对象
    def do_something(data_path, out_path, threads, myparam):
        # python code
    do_something(snakemake.input[0],snakemake.output[0],
            snakemake.threads, snakemake.config[“myparam”])
在R和R Markdown 中，是一个名为snakemake 的 S4 对象&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;do_something&amp;lt;function(data_path, out_path, threads, myparam){
    #R code
}

do_something(snakemake@input[[1]],snakemakeQoutput[[1]],
        snakemakeGthreads,snakemake@config[[&quot;myparam&quot;]])
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Julia 和 Rust 中也有与 Python 类似的 snakemake 对象，而在 Bash 中就不太一样。d于没有面向对象，所以提供了名为 snakemake_&lt;directive&gt;的数组，其中 directive 可以是:input、output、log、wildkards、resources、params、config 。没有包含的关键词使用 snakemake 访问。例如
    rule align:
        input:
            &quot;{sample}.fq&quot;,
            reference=&quot;ref.fa&quot;,
        output:
            &quot;{sample}.sam&quot;
        params:
            opts=&quot;-a-x map-ont&quot;,
        threads: 4
        Log:
            &quot;align/{sample}.log&quot;
        conda:
            &quot;envs/align.yaml&quot;
        script:
            &quot;scripts/align.sh&quot;
如果要在 Bash 脚本中访问命名的属性，需要直接将属性名称作为索引来访问
    #!/usr/bin/env bash
    echo &quot;Aligning sample ${snakemake_wildcards[sample]} with minimap2&quot; 2&amp;gt;&quot;${snakemake_log[0]}&quot;
    minimap2 ${snakemake_params[opts]}-t ${snakemake[threads]}&quot;${snakemake_input[reference]}&quot; \
    &quot;$isnakemake_input[0]}&quot;&amp;gt;&quot;${snakemake_output[0]}&quot; 2&amp;gt;&amp;gt;&quot;${snakemake_log[e]}&quot;
其中 snakemake_wildcards[sample]访问的是名为 sample 的通配符，snakemake[threads]访问的数线程数，snakemake_params[opts]访问的是 params内的 opts 属性的值。&lt;/directive&gt;&lt;/p&gt;

&lt;p&gt;当输入文件是一个列表时，由于 Bash 中并没有嵌套数组，所以需要将其转换为空格分隔的字符串，再转换为数组。例如&lt;br /&gt;
    rule align:
        input:
            reads=[“{sample}_R1.fq”,”{sample}_R2.fq]”],
            reference=”ref.fa”,
        output:
            reads=(${snakemake_input[reads]})#不要用双引号
            r1=”${reads[o]}”
            r2=”${reads[1]}”
保护文件和临时文件
一些比较耗时且大型的文件，我们可能想保护它免受意外删除或覆盖，可以使用 protected
    rule NAME:
        input:
            “path/to/inputfile”
        output:
            protected(“path/to/outputfile”)
        shell:
            “somecommand {input} {output}”
        或者有些临时文件，希望执行完程序之后就立马删除，释放空间，可以使用temp
        rule NAME:
            input:
                “path/to/inputfile”
            output:
                temp(“path/to/outputfile”)
            shell:
                “somecommand {input} {output}”&lt;/p&gt;
&lt;h3 id=&quot;输出目录&quot;&gt;输出目录&lt;/h3&gt;
&lt;p&gt;有时候也可以将目录作为输出，但是最好加上 directory 可以避免一些删除操作将重要文件删了。而且一些对目录下文件的修改会更新文件夹的时间戳，snakemake 会对每个规则的输入和输出文件的时间戳进行比较，从而判断是否需要重新执行该规则
    rule NAME:
        input:
            “path/to/inputfile”
        output:
            directory(“path/to/outputdirn”)
        shell:
            “somecomand {input} {output}”
        使用 ancient 函数可以忽略时间戳，始终认为该文件早于所有输出文件
    rule NAME:
        input:
            ancient(“path/to/inputfile”)
        output:
            “path/to/outputfile”
        shell:
            “somecommand {input} {output}”
输出文件将仅被创建一次，重复运行该规则不会再创建，即便输入文件后面也被修改了，只有强制执行回重新创建该文件。&lt;/p&gt;

&lt;h3 id=&quot;文件检查&quot;&gt;文件检查&lt;/h3&gt;
&lt;p&gt;使用 ensure 函数可以对文件是否为空或校验码进行检查
    rule NAME:
        output:
            ensure(“test.txt”,non_empty=True)
            ensure(“test.txt”，sha256=”u98a9cjsd98saud090923Bkpoask6f9B32”)
        shell:
            “somecommand {output}”
校验码也可以是一个函数
    def get_checksum(wildcards):
        return my_checksums[wildcards.sample]&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rule NAME:
    output:
        ensure(&quot;test/{sample}.txt&quot;,sha256 get_checksum)
    shell:
        &quot;somecommand {output}&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;重试&quot;&gt;重试&lt;/h3&gt;
&lt;p&gt;有些时候，某些规则并不是总能成功运行，有一定的失败概率。比如，进行网络访问或下载时可能会出现网络波动或故障。对于这种情况，可以通过retries 关键字为该规则中的每个作业定义重试的次数
    rule a:
        output :
            “test.txt”
        retries: 3
        shell:
            “curl https://some.unreliable.server/test.txt &amp;gt; {output}”
将函数作为输入
输入文件可以是单个字符串或字符串列表的形式，还可以使用返回值是一个或多个输入文件的函数，例如，使用通配符获取输入文件&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;def myfunc(wildcards):
    return【... a list of input files depending on given wildcards ...]
  
rule:
    input :
        myfunc
    output:
        &quot;someoutput.{somewildcard}.txt&quot;
    shell: 该函数必须以通配符对象作为第一个参数。 如果雨数的返回值是一个字典，则需要在雨数的外面嵌套一个 unpack 兩数，其作用相当于用键值对定义了输入文件
def myfunc(wildcards):
    return {&apos;foo&apos;:&apos;{wildcards.token}.txt&apos;.format(wildcards=wildcards)}

rule:
    input:
        unpack(myfunc)
    output:
        &quot;someoutput.{token}.txt
    shell:
        &quot;... {input.foo}”
如果不是直接使用函数名，而是以调用雨数的方式，则需要使用 Python 的解包操作
def myfunc1():
    return [&apos;foo.txt&apos;]

def myfunc2():
    return {&apos;foo&apos;: &apos;nowildcards.txt&apos;}

rule:
    input :
        *myfunc1(),
        **myfunc2(),
    output:
        ...
    shell:
        ... ### 规则依赖 在我们编写项目时，基本上都会涉及到前一个规则的输出文件作为后一个规则的输入文件，如果我们只是将文件名拷贝一份，那么当需要修改文件名时就会变得非常麻烦。我们可以使用 rules 对象来引用其他规则中的值，例如 rule a: input:&quot;patn/to/input output:a=&quot;path/to/output&quot;,b=&quot;path/to/output2” shell: rule b: input: rules.a.output.a output:&quot;path/to/output/of/b&quot; shell:a 规则 b 中，直接引用了规则 a 的输出文件，修改 a 中的输出文件名，并不会影响其他引用到它的规则。 本地任务 在集群环境中，并非所有规则都需要提交到集群中进行计算，比如一些下栽规则， a11 规则等一些不需要密集计算的任务。可以使用关键字 localrules 将规则标记为本地，这样它就不会提交到集群而是在主机节点上执行 localrules: all, foo rule all: input: rule foo: rule bar:
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;上面的规则中只有 bar 会提交到集群上。注意，localrules 指令可以多次使用，会自动将所有结果合并&lt;/p&gt;
&lt;h3 id=&quot;拆分与合并&quot;&gt;拆分与合并&lt;/h3&gt;
&lt;p&gt;当有些文件较大时，我们可以将其拆分为较小的部分，然后分部分计算，最后将计算后的结果进行合并。这种操作一般在序列比对时较常用到，当比对的 fastq 数据过大时，可以将其拆分为 10-20 个小的 fastq，然后进行并行比对，加快比对的速度。这时，我们可以使用scattergather 定义全局的拆分，例如
    scattergather:
        split=8
然后，在 scatter 和 gather 对象中会有一个名为 split 这个拆分和聚合方法。这个两个对象中调用的方法名称与 scattergather 中定义的拆分名称一样
    rule all:
        input:
        “gathered/all.txt”&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    rule solit:
    input:
    &quot;content.txt&quot;
    output:
    scatter.split(&quot;splitted/{scatteritem}.txt&quot;)#拆分params:
    chunks=8shell:
    &quot;split -n {params.chunks}-numeric-suffixes=1 --suffixlength=1-additional-suffix=-of-8,txt {input} splitted/&quot;
    rule intermediate:
    input:
    &quot;splitted/{scatteritem}.txt&quot;
    output:
    &quot;splitted/{scatteritem}.post.txt&quot;
    shell:
    &quot;cp finput} {output}&quot;

    rule gather:
    input:
    gather.split(&quot;splitted/{scatteritem} .post.txt&quot;)output:
    &quot;gathered/all.txt&quot;
    shell:
    &quot;cat {input} &amp;gt; {output}&quot; 其中 scatteritem 会变成 i-of-n，其中 n 就是前面定义的 split 拆分的数量，1 为 1-n 之间的值。所以需要保证拆分出来的文件名称正确
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;规则继浜&quot;&gt;规则继浜&lt;/h3&gt;
&lt;p&gt;可以从先前定义的规则继承，以修改的方式重用现有规则。例如
    rule a:
        output:
            “test.out”
        shell:
            “echo test &amp;gt; {output}
    use rule a as b with:
        output:
            “test2.out”
使用 se 语句，规则 b承自 a，并使用 with 语句修改其中的输出文件为test2.out 。除了规则中的执行命令或脚本，其他项的值都是可修改的。&lt;/p&gt;

&lt;h2 id=&quot;3-配置文件&quot;&gt;3. 配置文件&lt;/h2&gt;
&lt;p&gt;Snakemake 允许使用配置文件来定义一些用户自定义变量的值，如样本信息、数据路径、软件参数和一些流程控制参数等，可以使工作流程更加灵活。&lt;/p&gt;
&lt;h3 id=&quot;标准配置文件&quot;&gt;标准配置文件&lt;/h3&gt;
&lt;p&gt;snakemake 支持 JSON 和 YAML 格式的配置文件，可以使用 configfile 关键字来声明配置文件
    configfile:”path/to/config.yaml
在流程中处于该声明之后的地方，都可以使用 config 全局字典变量对配置信息进行访问。如果要在 shell 命令添加占位符，需要将健名两侧的引号去掉。例如
    parals:
        path = config[‘path’]
    shell:
        “mycommand {config[foo]}
如果未使用 configfile 语句声明，则 config 变是将是一个空数组。除了 configfile语句之外，还可以通过命令行覆盖配置项的值，例如:
snakemake–config yourparam=1.5
或者使用 –configfile 命令行参数指定配置文件。这三种方式设置的配置项会汇总在一起，如果存在相同的配置项，则命令行的值优先。
表格配置文件
当然并不是所有信息都适合用 YAHL或 JS0N 来表示，像样本信息这种通常以表格数据的形式展现会比较好，可以使用 pandas 来直接读取文件中的数据
    import pandas as pd
    samples = pd.read_table(config[“samples_info”]).set_index(“samples”,drop=False)
这可以作为配置文件的补充，从配置文件中指定的样本信息文件中读取样本的所有信息，免去在配置文件中进行指定。&lt;/p&gt;

&lt;h3 id=&quot;验证&quot;&gt;验证&lt;/h3&gt;
&lt;p&gt;我们编写的流程时，应该只将配置文件作为接口，通过修改配置文件信息就可以运行流程，因此，对配置文件的格式进行验证，是保证流程顺利运行的关键，snakemake 提供了nakemake.utils.validate 函数可以对配置文件(也可以是 pandas 的数据框)进行验证。其验证方式通过 JSON schemas 指定，例如
    import pandas as pd
    from snakemake.utils import validate
    configfile: “config.yaml”
    validate(config,”config.schema.yam”)
    samples = pd,read_table(config[“samples”]).set index(“sample”drop=False)
    validate(samples,”samples.schema.yaml”)&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rule all:
    input:
        expand(&quot;test.{sample}.txt&quot;,sample=samples.index)
   
rule a:
    output:
        &quot;test.{sample}.txt&quot;
        76
    shell:
        &quot;touch {output}&quot; 分别对配置文件和数据框的格式进行验证，配置文件需要根其中包含的字段设置验证，例如配置文件 config.schema.yamL中有GENOME、GENES 和FASTA 三个字段， GENOME 单面又包含两个字段，里面的字段也需要添加一个properties 去验证
$schema:&quot;http://json-schema.org/draft-86/schema#
description: config file schema
properties:
    GENOME:
        type: object
    description: path to a bowtie2 index
    properties:
        name :
            type: string
        path:
            type: string
    GENES:
        type: string
        description: path to a BED6 file with gene name as the 4th column
    FASTA:
        type: string
        description: path to a FAsTQ file corresponding to the GENOME
required:
    - GENOME
    - GENES
    - FASTA 数据框的验证内容需要对每一列进行验证，例如saples.schema.vaml
$schema: &quot;https://json-scheaa.org/draft-86/schema#&quot;
description: an entry in the sample sheet
properties:
    sample:
        type: string
        description: sample name/identifier
    condition;
        type: string
    description:sample condition that will be compared duringdifferential expression analysis (e.g. a treatment, a tissue time, adisease) case: type: boolean default: true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;description: boolean that indicates if sample is case or control&lt;/p&gt;

&lt;p&gt;required:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;sample
-condition
    &lt;h3 id=&quot;环境变量&quot;&gt;环境变量&lt;/h3&gt;
    &lt;p&gt;有些配置信息并不适合写入到文本文件中，例如账号密码和 token 等，我们可以将这些信息先写入到系统的环境变量中，然后在流程中使用
envvars:
“SOME_VARIABLE”
rule do_something:
output:
“test.txt”
parans:
x=os.environ[“SOME_VARIABLE”]
shell:
“echo iparams.x}&amp;gt; {output}”&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;snakemake 文件中所指定的所有路径相对路径都是相对于当前运行目录而言的，可以通过在文件中使用关键字 workdir 来指定工作目录&lt;/p&gt;

&lt;p&gt;workdir:”path/to/workdir”
工作路径也可以使用配置文件指定，然后在此处设置为配置文件中所设置的配置项&lt;/p&gt;
&lt;h2 id=&quot;4模块化&quot;&gt;4.模块化&lt;/h2&gt;

&lt;p&gt;snakemake模块化主要分为 4个层级&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;最底层的封装是包装器，将实际运行的代码进行封装，只暴露出输入输出接口。并通过与 conda结合，将软件的依赖性部署到一个隔离的环境。这些封装器可以发布到Snakemake Wrapper Repository 或直接使用上面写好的封装器&lt;/li&gt;
  &lt;li&gt;将功能细化，执行同一功能的规则写在一个 Snakefile 里面，并在主要的那个Snakefile 里面使用 include 将该功能导入，所有的 Snakefile 共享同一个配置文件&lt;/li&gt;
  &lt;li&gt;通过 mudule 语句可以任意组合和重用规则&lt;/li&gt;
  &lt;li&gt;定义子流程，但是不推荐
    &lt;h4 id=&quot;封装器&quot;&gt;封装器&lt;/h4&gt;
    &lt;p&gt;使用 wrapper 关键字声明封装器，例如
 rule samtools_sort:
     input:
         “mapped/{sample}.bam”
     output:
         “mapped/{sample}.sorted.bam”
     parans :
         #-m GG*
     threads: 8
     wrapper:
         “0.0.8/bio/samtools/sort”
上面使用了 Snakemake Wrapper Rcpository 中定义的对 bam 文件排序的封装器，其封装了samtools sort 程序的功能，会自动解析传入的输入输出文件，以及额外的参数等，解析后执行相应的排序指令。
其中 0.0.8 表示的是封装的版本，上面封装了一些常用的生信分析软件，为了省事可以直接使用上面的封装器而不需要自己再重写相应的命令或脚本。
当然，我们也可以提供完整的 URL 或本地路径来添加自定义或其他人提供的封装器。如果是本地的封装器，可以使用绝对路径(file://path/to/wrapper)和相对路径两种方式( file:path/to/wrapper )
在线的则需要提供完整的文件URL，例如使用上传到 GitHub 上的封装器，注意是raw 版本
 wrapper:
     https://github.com/snakemake/snakemake
     wrappers/raw/8.8.8/bio/samtools/sort
封装器的文件结构一般是，有三个文件是必须的environment.yaml、meta.yaml 和wrapper.py .
 |–environment.yaml
 |– meta.yaml
 |– test
 |– a.bam
 |  |– a.bam,bai
 |  |– Snakefile
 |– wrapper.py
其中 environment.yaml 定义了该封装所依赖的环境，涉及使用到的包及软件， conda 将根据该文件搭建环境，其内容主要包括
 channels:
     -conda-forge
     - bioconda
     - nodefaults
 dependencies:
     - samtools =1.14
meta.yaml 是关于该封装的一些基本信息的描述。 wrapper.py 是该封装的具体处理代码，该文件不仅仅可以是 Python 脚本，也可以是其他编程语言(R、Julia、 Rust 和Bash )编写的脚本。&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;在一个 Snakefile 文件中导入另一个 $nakefile 中定义的规则，使用 include 关键字会一次将所有规则导入
include: “path/to/other/snakefile’&lt;/p&gt;

&lt;h2 id=&quot;模块&quot;&gt;模块&lt;/h2&gt;
&lt;p&gt;使用 module 关键字可以将其他流程(可以是本地文件也可以是 URL)定义为一个模块
    from snakemake.utils import min_version
    module other_workflow:
    snakefile:
    “other workflow/snakefile”
    use rule * from other_workflow exclude ruleC as other_*
其中 use rule * from other_workflow exclude rulec 表示导入模块中除了 rulec 之外的所有规则， as other_&lt;em&gt;表示将这些导入的规则都添加了一个 other_ 前缀，可以防止规则重名造成的冲突。其中 *表示的是所有，如果只要导入某个规则，可以将其替换成对应的规则名称。
我们也可以为模块指定配置参数，覆盖模块中原先指定的配置文件，同时可以在module中跳过参数的检查，也可以使用 with 修改规则
    from snakemake.utils import min_version
    configfile: “config/config.yaml&lt;/em&gt;
    module other_workflow:
    snakefile:”other_workflow/Snakefile”config: config[“other-workflow”]
    skip_validation: True
    use rule * from other_workflow as other_*&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;use rule some_task from other_workflow as other_some_task with:output:
&quot;results/some-result.txt&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;5状态通知&quot;&gt;5.状态通知&lt;/h2&gt;
&lt;p&gt;我们可以在流程运行的不同状态下，进行不同的操作，例如在启动分析时，打印消息，在分析成功或失败是输出提示，可以用到三个关键字
    onstart:
    print(“workflow start”)
    onsuccess:
    print(“Workflow finished, no error”)
    onerror:
    print(“An error occurred”)&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;shell(&quot;mail-s &quot;an error occurred&quot;) # 执行流程 在这里，我们主要介绍一些如何运行前面定义的流程，snakemake 是通过命令行来运行，可以运行在本地或集群上 ## 命令行 ### 1.命令行参数 定义流程使用的核心数
snakemake -cores 1 Snakemake 默认会执行在同一日录中名为 Snakefile 的文件所定义的工作流，也可以通过参数-s 绐出 Snakefile 。 试运行流程
snakemake -n 此外，可以打印每个规则执行的原因
snakemake -n -r 为特定的规则重新指定线程数和资源
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;snakemake–set-threads myrule=2cores
snakemake–set-resources myrule:partition=”foocores 4&lt;/p&gt;
&lt;h3 id=&quot;2-profile&quot;&gt;2. profile&lt;/h3&gt;
&lt;p&gt;snakemake 包含非常多的参数，如果都写在命令行将会非常臃肿，且不够简洁且容易出错此时，可以使用 -profile 参数来设置一个配置文件，将參数写入到文件中方便使用和查
snakemake -profile myprofile
这里传入的 myprofile 其实是一个文件夹，文件夹中需要一个名为 config.yaml 的配置文件，这个文件夹可以是绝对路径也可以是相对路径，如果该路径添加到了环境变量中，也可以直接传入该变量名。
例如， config.yaml 文件中存贮如下信息
cluster: qsub
jobs: 100
表示使用 qsub 提交到集群，且并行任务不超过 10日个，也可以使用 -cluster 参数，例
snakemake –cluster gsub–jobs 188
两种方式是等价的，但通常我没可能还需要指定一些其他参数，所以使用 profile 的形式会更好k
由于我使用的是 slurm 任务调度工具，下面我简单介绍一些其配置。根据官方推荐的使用方式，我们可以直接从模板中构建自己的配置信息。首先需要安装ookiecutter
mamba install cookiecutter
然后选择一个合适的目录来存储相应的 prof1le，例如
mkdir -p config
cd config
cookiecutter https://github.com/snakemake-Profiles/slurm.git&lt;/p&gt;

&lt;p&gt;运行时会有提示信息，用于设置一些常用的参数值，新建成功之后在目录下会有一个名为slurm 文件夹，里面包含如下文件
CookieCutter.py
config.yaml
settings.json
slurm-jobscript.sh
slurm-sidecar.py
slurm-status.py
slurm-submit.py
slurm_utils.py
其中 config.yaml 里面包含了刚才设置的值，也可以自行添加或删除相应的参数。里面的参数可能是像这样的。由于我的系统中没有开发 sacct软件的使用，所以我把它注释了
jobscript:”slurm-jobscript.sh
cluster:”slurm-submit.py”&lt;/p&gt;
&lt;h1 id=&quot;custer-statusslurm-statuspy&quot;&gt;custer status:”slurm-status.py”&lt;/h1&gt;
&lt;p&gt;max-jobs-per-second:“1”
max-status-checks-per-second:“10”
local-cores:1
latency-wait:”5”
use-conda: “True”
use-singularity: “False”
10jobs: “100”
11
12
printshellcmds: “False”
rerun-incomplete:”True&lt;/p&gt;
&lt;h3 id=&quot;3可视化&quot;&gt;3.可视化&lt;/h3&gt;
&lt;p&gt;使用 –dag参数，可以将整个流程以流程图的形式展现
snakemake-dagldot -Tpdf &amp;gt; dag.pdf&lt;/p&gt;

&lt;p&gt;snakemake–rulegraph|dot -Tpdf &amp;gt; dag_rules.pdf # 规则之间的运行关系&lt;/p&gt;
&lt;h1 id=&quot;项目展示&quot;&gt;项目展示&lt;/h1&gt;
&lt;p&gt;通过学习上面的内容，根据网上搜索到的一些流程，我自己也写了一个简单的 cut&amp;amp;Tag 数据分析流程，其大致流程如下&lt;/p&gt;

&lt;p&gt;主要包含一些上游的数据处理和分析，后续会陆续添加一些分析方法，不断完善。整个项目的布局如下&lt;/p&gt;
</description>
        <pubDate>Sat, 22 Jun 2024 03:16:52 +0000</pubDate>
        <link>https://liuxm0239.github.io/2024/06/22/snakemake/</link>
        <guid isPermaLink="true">https://liuxm0239.github.io/2024/06/22/snakemake/</guid>
        
        <category>Bioinfo</category>
        
        <category>Linux</category>
        
        <category>python</category>
        
        
        <category>基因组学</category>
        
        <category>操作系统强迫症</category>
        
      </item>
    
      <item>
        <title>postgreSQL 服务器版</title>
        <description>&lt;ul&gt;
  &lt;li&gt;content&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h1 id=&quot;安装postgresql&quot;&gt;安装PostgreSQL&lt;/h1&gt;

&lt;h1 id=&quot;1-更新ubuntu包&quot;&gt;1. 更新ubuntu包&lt;/h1&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo apt-get update&lt;/code&gt;&lt;/p&gt;

&lt;h1 id=&quot;2-安装postgresql&quot;&gt;2. 安装postgreSQL&lt;/h1&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo apt install postgresql postgresql-contrib&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;以上命令成功运行后，postgresql已经正常安装，安装完成以后会自动启动postgresql的服务。可通过以下信息查看postgresql的信息&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# 查看postgresql版本
sudo -u postgres psql -c &quot;SELECT version();&quot;
# 查看postgresql服务是否启动

#sudo systemctl enable postgresql.service
#sudo systemctl start postgresql.service
sudo systemctl status postgresql.service
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;3-进行数据库配置&quot;&gt;3. 进行数据库配置&lt;/h1&gt;

&lt;h2 id=&quot;31-创建用户账号密码&quot;&gt;3.1 创建用户账号密码&lt;/h2&gt;

&lt;p&gt;在ubuntu上PostgreSQL数据库以后，会自动创建一个计算机用户postgres，以下是基于该账户进行操作的。&lt;/p&gt;

&lt;p&gt;运行以下命令，使用postgres用户登录postgresql&lt;/p&gt;

&lt;h3 id=&quot;进入交互界面&quot;&gt;进入交互界面&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo -i -u postgres psql&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;进行postgresql的交互界面后，可以通过运行以下信息进行用户创建&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;-- 创建不带密码的账号-root
create role root;
-- 创建带密码的账号-root
create user root with &apos;temp123&apos;;
-- 显示所有用户，并查看是否创建成功
\du
-- 更改postgresql密码,如修改root账号的密码
alter user root with password &apos;temp123#&apos;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;32-创建数据库&quot;&gt;3.2 创建数据库&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;-- 创建数据库(root)
create database root;
-- 删除数据库(root)
drop database test;
-- 查询所有数据库
\l
-- 切换数据库root
\c root
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;33-创建schema&quot;&gt;3.3 创建schema&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;-- 创建schema(ods)，以下写法均可
 create schema ods;
 create schema if not exists ods;
-- 为某个用户(root2)创建market
 create schema market authorization roo2;
-- 查看当前数据库下的所有schema
select * from information_schema.schemata;
-- 删除schema(ods)
 drop schema if exists ods;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;34-用户权限授权&quot;&gt;3.4 用户权限授权&lt;/h2&gt;

&lt;p&gt;创建完用户密码以后，可以用以下命令对用户进行权限授予&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;-- 给用户root赋予超级用户权限
alter user root with superuser;
-- 给用户root2赋予普通权限
alter user  root2 with privileges; 
-- 把数据库的所有权限给予用户root
grant all privileges on database test to root;
-- 把某schema下(ods)的所有表(test用户下)的所有权限给予用户root2
grant all on all tables in schema ods to root2;
-- 把某张表（test_table）的所有权限给予用户root2
grant all on test_table to root2;
-- 把某张表（test_table）的查询权限给予用户root2
grant select on table test_table to root2;
-- 撤销用户root2的某个数据库(test)权限；
revoke all on database test from root2;
-- 撤销用户root2某个schema(ods)下所有表的修改(update)权限；
revoke update on all tables in schema ods from root2;
-- 撤销用户root2某张表（test_table）的所有权限
revoke privileges on test_table from root2;
-- 将某张表（test_table）的所有者给root2
alter table test_table owner to root2;
-- 允许用户(root)登录
ALTER ROLE root WITH LOGIN;
-- 禁止用户(root)登录
ALTER ROLE root WITH NOLOGIN;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;其他常用的一些授权如下&quot;&gt;其他常用的一些授权如下：&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;-- 设置user1为user的子用户
grant user1 to user;
-- 为user1增加schema增加使用权，schema名称为ods
GRANT usage ON SCHEMA ods TO user1;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;35-配置远程访问&quot;&gt;3.5 配置远程访问&lt;/h2&gt;

&lt;p&gt;由于postgresql在安装时会默认添加一个用户名为postgres的ubuntu系统用户，因此要先用其他账户删除postgres用户的密码，再配置属于自己的密码。&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# 删除postgres用户的密码
sudo passwd -d postgres
# 设置postgres用户的密码
sudo -u postgres passwd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;配置完密码后，编辑/etc/postgresql/12/main/postgresql.conf文件&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo vim /etc/postgresql/12/main/postgresql.conf&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;在上述配置文件postgresql.conf中添加以下内容:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;listen_addresses = &apos;*&apos; 
password_encryption = scram-sha-256
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;运行以下命令，编辑/etc/postgresql/12/main/pg_hba.conf文件&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo vim /etc/postgresql/12/main/pg_hba.conf &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;在pg_hba.conf文件末尾追加以下内容：
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;host    all             all             0.0.0.0/0               scram-sha-256&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;添加完成后，保存退出，然后重启postgresql 服务。&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo systemctl start postgresql.service&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;36-远程连接&quot;&gt;3.6 远程连接&lt;/h2&gt;

&lt;p&gt;开放服务器的5432 端口：&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo ufw allow 5432/tcp
sudo ufw reload
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;运用上述获得的信息，可以使用客户端或者命令行连接postgresql数据库。
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;psql -h 192.1.1.1 testdb -U root -W -p 5432&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;37-卸载&quot;&gt;3.7 卸载&lt;/h2&gt;

&lt;h3 id=&quot;移除postgresql&quot;&gt;移除postgresql&lt;/h3&gt;

&lt;p&gt;sudo apt-get –purge remove postgresql*&lt;/p&gt;

&lt;h3 id=&quot;移除配置信息&quot;&gt;移除配置信息&lt;/h3&gt;

&lt;p&gt;sudo rm -r /etc/postgresql/
sudo rm -r /etc/postgresql-common/
sudo rm -r /var/lib/postgresql/
sudo userdel -r postgres
sudo groupdel postgres&lt;/p&gt;

&lt;h1 id=&quot;参考&quot;&gt;参考&lt;/h1&gt;

&lt;p&gt;&lt;a href=&quot;https://juejin.cn/post/7132761848947933220&quot;&gt;一文弄懂ubuntu安装postgresql以及开启远程访问&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://blog.csdn.net/qq_41780234/article/details/126083484&quot;&gt;如何在ubuntu环境下安装postgresql并配置远程访问&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Fri, 14 Jun 2024 03:23:51 +0000</pubDate>
        <link>https://liuxm0239.github.io/2024/06/14/postgres/</link>
        <guid isPermaLink="true">https://liuxm0239.github.io/2024/06/14/postgres/</guid>
        
        <category>SQL</category>
        
        
        <category>数据库</category>
        
      </item>
    
      <item>
        <title>生存分析</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#生存分析的步骤&quot; id=&quot;markdown-toc-生存分析的步骤&quot;&gt;生存分析的步骤&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#单因素和多因素cox回归分析&quot; id=&quot;markdown-toc-单因素和多因素cox回归分析&quot;&gt;单因素和多因素cox回归分析&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;p&gt;2021 年的时候,有段时间专门研究了下生存分析.当时想了很久,怎么用直观的例子来类比生存分析,后来用了不同放射物下的“薛定谔的猫猫”做类比,就容易理解了一些.&lt;/p&gt;

&lt;h2 id=&quot;生存分析的步骤&quot;&gt;生存分析的步骤&lt;/h2&gt;
&lt;ol&gt;
  &lt;li&gt;首先做单因素cox挑选显著相关特征&lt;/li&gt;
  &lt;li&gt;然后用挑选出的多个特征，做多因素cox&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;单因素和多因素cox回归分析&quot;&gt;单因素和多因素cox回归分析&lt;/h1&gt;

&lt;p&gt;前面我们讲过一个R函数搞定风险评估散点图，热图，其中LASSO模型的输入就是单因素cox分析得到的显著与生存相关的基因。今天我们就来探讨一下如何使用R来做单因素和多因素cox回归分析。&lt;/p&gt;

&lt;p&gt;我们用R的survival包自带的一套肺癌的数据来举例&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#安装下面两个R包
install.packages(c(&quot;survival&quot;, &quot;survminer&quot;))
​
#加载这两个R包
library(&quot;survival&quot;)
library(&quot;survminer&quot;)
​
#加载肺癌这套数据
data(&quot;lung&quot;)
#显示前6行
head(lung)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;这里每一行是一个样本，从第三列开始每一列是一个特征
&lt;img src=&quot;https://pic1.zhimg.com/80/v2-277d2fc984d795b2e0d73c5c32e4385c_720w.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;单因素cox回归分析&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;对单个特征进行cox回归分析，看它是否与样本的生存显著相关&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#单因素cox回归分析，这里看性别sex这个特征
res.cox &amp;lt;- coxph(Surv(time, status) ~ sex, data = lung)
res.cox
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;可以看到这里算出来的p值是0.00149，是显著的
&lt;img src=&quot;https://pic2.zhimg.com/80/v2-dc61f7f11d859a5e58b8982c97f56ce9_720w.jpg&quot; alt=&quot;&quot; /&gt;
我们在来看一下summary&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;summary(res.cox)&lt;/code&gt;
这里的exp(coef)就是HR（hazard ratio，风险率），lower .95和upper .95为95%的置信区间
&lt;img src=&quot;https://pic1.zhimg.com/80/v2-800b0cd3b963d69ad2e56ddde0180b44_720w.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;批量单因素cox回归分析&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;一般我们的关注的特征都比较多，用上面的代码一个一个来做单因素cox回归分析效率太低了，下面我们来看看如何批量做单因素cox回归分析。&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#假设我们要对如下5个特征做单因素cox回归分析
covariates &amp;lt;- c(&quot;age&quot;, &quot;sex&quot;,  &quot;ph.karno&quot;, &quot;ph.ecog&quot;, &quot;wt.loss&quot;)
#分别对每一个变量，构建生存分析的公式
univ_formulas &amp;lt;- sapply(covariates,
                        function(x) as.formula(paste(&apos;Surv(time, status)~&apos;, x)))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;img src=&quot;https://pic2.zhimg.com/80/v2-64471772fb6f57be769fc7ad2ad1a2e9_720w.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#循环对每一个特征做cox回归分析
univ_models &amp;lt;- lapply( univ_formulas, function(x){coxph(x, data = lung)})
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;img src=&quot;https://pic4.zhimg.com/80/v2-d760382d4783bcf4ea75bc5810bb3287_720w.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#提取HR，95%置信区间和p值
univ_results &amp;lt;- lapply(univ_models,
                       function(x){
                         x &amp;lt;- summary(x)
                         #获取p值
                         p.value&amp;lt;-signif(x$wald[&quot;pvalue&quot;], digits=2)
                         #获取HR
                         HR &amp;lt;-signif(x$coef[2], digits=2);
                         #获取95%置信区间
                         HR.confint.lower &amp;lt;- signif(x$conf.int[,&quot;lower .95&quot;], 2)
                         HR.confint.upper &amp;lt;- signif(x$conf.int[,&quot;upper .95&quot;],2)
                         HR &amp;lt;- paste0(HR, &quot; (&quot;,
                                      HR.confint.lower, &quot;-&quot;, HR.confint.upper, &quot;)&quot;)
                         res&amp;lt;-c(p.value,HR)
                         names(res)&amp;lt;-c(&quot;p.value&quot;,&quot;HR (95% CI for HR)&quot;)
                         return(res)
                       })
#转换成数据框，并转置
res &amp;lt;- t(as.data.frame(univ_results, check.names = FALSE))
as.data.frame(res)
write.table(file=&quot;univariate_cox_result.txt&quot;,as.data.frame(res),quote=F,sep=&quot;\t&quot;)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;得到的结果如下，你会发现对于sex这个特征来说，结果跟前面单独做得到的结果是一样的。
&lt;img src=&quot;https://pic2.zhimg.com/80/v2-281c81b8a2a57c7c7c38cdb086c92441_720w.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;多因素cox回归分析&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;mark&gt;**前面是单独看每一个特征是否跟生存相关，而多因素cox回归是同时检测多个特征是否与生存相关。
一般先通过单因素cox回归分析找出与生存显著相关的特征，然后基于这些特征再去做多因素cox回归分析，或者做LASSO分析。**&lt;/mark&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;res.cox &amp;lt;- coxph(Surv(time, status) ~ age + sex + ph.karno + ph.ecog, data =  lung)
x &amp;lt;- summary(res.cox)
pvalue=signif(as.matrix(x$coefficients)[,5],2)
HR=signif(as.matrix(x$coefficients)[,2],2)
low=signif(x$conf.int[,3],2)
high=signif(x$conf.int[,4],2)
multi_res=data.frame(p.value=pvalue,
                     HR=paste(HR,&quot; (&quot;,low,&quot;-&quot;,high,&quot;)&quot;,sep=&quot;&quot;),
                     stringsAsFactors = F
)
multi_res
write.table(file=&quot;multivariate_cox_result.txt&quot;,multi_res,quote=F,sep=&quot;\t&quot;)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;得到的结果如下
&lt;img src=&quot;https://pic1.zhimg.com/80/v2-26a88269585d94abe8895154afb2d3c8_720w.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;完整代码参考&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.sthda.com/english/wiki/cox-proportional-hazards-model&quot;&gt;raw&lt;/a&gt;
&lt;a href=&quot;https://mp.weixin.qq.com/s?__biz=MzI4ODE0NTE3OA==&amp;amp;mid=2649207612&amp;amp;idx=1&amp;amp;sn=af4480273740bd1c397bf1e7a050497c&amp;amp;chksm=f3d1f949c4a6705f6ff777bae3ef4a11e4a61693c55d59fa7131eb236da253a4b07157067254&amp;amp;token=1784749928&amp;amp;lang=zh_CN#rd&quot;&gt;wechat link&lt;/a&gt;
​&lt;/p&gt;
</description>
        <pubDate>Wed, 17 Jan 2024 03:18:45 +0000</pubDate>
        <link>https://liuxm0239.github.io/2024/01/17/Survival-Analysis/</link>
        <guid isPermaLink="true">https://liuxm0239.github.io/2024/01/17/Survival-Analysis/</guid>
        
        <category>统计学习方法</category>
        
        
        <category>统计学习</category>
        
      </item>
    
      <item>
        <title>Becoming a Data Scientist(rp)</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#数据科学技能&quot; id=&quot;markdown-toc-数据科学技能&quot;&gt;数据科学技能&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#数学&quot; id=&quot;markdown-toc-数学&quot;&gt;数学&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#统计学&quot; id=&quot;markdown-toc-统计学&quot;&gt;统计学&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#算法&quot; id=&quot;markdown-toc-算法&quot;&gt;算法&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#数据可视化&quot; id=&quot;markdown-toc-数据可视化&quot;&gt;数据可视化&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#商业知识&quot; id=&quot;markdown-toc-商业知识&quot;&gt;商业知识&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#领域专长&quot; id=&quot;markdown-toc-领域专长&quot;&gt;领域专长&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#分析思维&quot; id=&quot;markdown-toc-分析思维&quot;&gt;分析思维&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#数据科学工具&quot; id=&quot;markdown-toc-数据科学工具&quot;&gt;数据科学工具&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#文件格式&quot; id=&quot;markdown-toc-文件格式&quot;&gt;文件格式&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#excel&quot; id=&quot;markdown-toc-excel&quot;&gt;EXCEL&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#sql&quot; id=&quot;markdown-toc-sql&quot;&gt;SQL&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#python&quot; id=&quot;markdown-toc-python&quot;&gt;PYTHON&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#r&quot; id=&quot;markdown-toc-r&quot;&gt;R&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#大数据工具&quot; id=&quot;markdown-toc-大数据工具&quot;&gt;大数据工具&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#hadoop&quot; id=&quot;markdown-toc-hadoop&quot;&gt;HADOOP&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#nosql&quot; id=&quot;markdown-toc-nosql&quot;&gt;NOSQL&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#联系起来-数据处理过程中的工具&quot; id=&quot;markdown-toc-联系起来-数据处理过程中的工具&quot;&gt;联系起来︰ 数据处理过程中的工具&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#数据收集&quot; id=&quot;markdown-toc-数据收集&quot;&gt;数据收集&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#数据处理&quot; id=&quot;markdown-toc-数据处理&quot;&gt;数据处理&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#探索性分析&quot; id=&quot;markdown-toc-探索性分析&quot;&gt;探索性分析&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#数据分析&quot; id=&quot;markdown-toc-数据分析&quot;&gt;数据分析&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#数据呈现&quot; id=&quot;markdown-toc-数据呈现&quot;&gt;数据呈现&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#开始求职&quot; id=&quot;markdown-toc-开始求职&quot;&gt;开始求职&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#构建数据科学项目集和简历&quot; id=&quot;markdown-toc-构建数据科学项目集和简历&quot;&gt;构建数据科学项目集和简历&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#在哪里找工作&quot; id=&quot;markdown-toc-在哪里找工作&quot;&gt;在哪里找工作&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#数据科学面试宝典&quot; id=&quot;markdown-toc-数据科学面试宝典&quot;&gt;数据科学面试宝典&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#你会看到几类常见问题&quot; id=&quot;markdown-toc-你会看到几类常见问题&quot;&gt;你会看到几类常见问题：&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;

&lt;p&gt;英文原文地址：&lt;a href=&quot;http://blog.yhat.com/posts/become-a-data-scientist.html&quot;&gt;Becoming a Data Scientist&lt;/a&gt;
&lt;a href=&quot;https://vip.biotrainee.com/assets/images/3-9ZnDpJwh3OmS6Nk4.jpeg&quot;&gt;image&lt;/a&gt;
—-&lt;/p&gt;
&lt;h1 id=&quot;数据科学技能&quot;&gt;数据科学技能&lt;/h1&gt;
&lt;p&gt;数据科学家每天都会用到很多综合技能，其中的许多技能都是在工作或者其他时间自学的。他们并不需要具备某种特定的文凭，而是来自不同的背景。&lt;/p&gt;

&lt;p&gt;本文讨论的所有技能都可以自学。我们为此准备了一些资源让你可以沿着这条路走下去。而你则可以把这篇文章看成是数据科学家的培养指南。&lt;/p&gt;

&lt;h2 id=&quot;数学&quot;&gt;数学&lt;/h2&gt;
&lt;p&gt;数学是数据科学的重要组成部分。请确保你了解从微积分到线性代数这些大学数学的基础知识。当然，关于数学你知道的越多越好。&lt;/p&gt;

&lt;p&gt;过大的数据量通常会显得笨拙且难以操作，这时你将不得不使用数学对你手头的数据进行处理和结构化。
如果你忘了本科阶段就该掌握的线性代数和微积分概念，别无选择，你必须要学会理解如何处理数据矩阵并大致了解其背后的数学算法。&lt;/p&gt;

&lt;p&gt;资源︰ 这个列表中的15门数学公开课可以帮你补上这些数学技能。另外，麻省理工学院也提供了关于数据科学的开放数学课程。&lt;/p&gt;

&lt;h2 id=&quot;统计学&quot;&gt;统计学&lt;/h2&gt;
&lt;p&gt;你必须知道那些可以从小数据集推断总体情况的统计学知识，这是数据科学的基本准则 。统计学将数据科学家的成长之路铺平道路。&lt;/p&gt;

&lt;p&gt;要知道统计学总是和数据结合在一起的，统计学将使你更好地理解所观察到的数据模型，并能提炼出做合理推论所需要的洞察力。例如，理解统计推断将帮助你从一个小样本中得到符合总体中每个个体的一般性结论。&lt;/p&gt;

&lt;p&gt;要理解数据科学你必须知道基本的假设检验，并且能设计实验来理解数据的意义和背景。&lt;/p&gt;

&lt;p&gt;资源︰ 我们的博客发布过一篇如何将贝叶斯定理，概率和统计结合起来的入门文章，这篇博客为你理解成为一名数据科学家需要的统计基础提供了一个很好的参考。&lt;/p&gt;

&lt;h2 id=&quot;算法&quot;&gt;算法&lt;/h2&gt;
&lt;p&gt;算法是让计算机遵循一定规则或模型的能力。在处理分析大数据时，了解如何使用机器来完成工作至关重要。&lt;/p&gt;

&lt;p&gt;为了让自己胜任数据科学中各种繁重的工作你不得不理解算法选择和优化背后的理论。你必须确定自己的问题是否需要进行回归分析或者需要用某种算法将不同数据点进行归类。&lt;/p&gt;

&lt;p&gt;你会想要知道很多不同的算法，也会想要学习机器学习的基本原理。所谓机器学习就是能让亚马逊基于你的购买历史记录向你推荐商品而无需人为干预。这类算法可以借助机器的力量来帮你挖掘信息。当然，为了处理大型数据集，你也需要机器来扩展你的思维。&lt;/p&gt;

&lt;p&gt;资源︰由KDNuggets提供的这份指南解释了十种常用数据科学算法，里面19个免费的公共数据集可以供你进行实践。&lt;/p&gt;

&lt;h2 id=&quot;数据可视化&quot;&gt;数据可视化&lt;/h2&gt;
&lt;p&gt;完成数据分析仅仅是成功的一半。为了扩大影响力，你不得不说服别人相信并且采纳你的观点。&lt;/p&gt;

&lt;p&gt;人是视觉动物。根据3M和Zabiscod的研究，传输到大脑的信息里几乎90%都是视觉化的，而且大脑对视觉信息的处理速度要比文本快60000倍。&lt;/p&gt;

&lt;p&gt;数据可视化是一门通过图表和其他可视化工具来呈现信息的艺术，从而使观众可以很容易地理解数据并从中提取观点。什么样的信息最适合在条形图中展示，哪种类型的数据又应该用散点图呈现呢？&lt;/p&gt;

&lt;p&gt;人类生而善于回应视觉线索。你呈现的数据结论越清晰，别人就越有可能根据你的结论而采取行动。&lt;/p&gt;

&lt;p&gt;资源︰ 这里有一篇博客供你参考。另外，Nathan Yau 的博客提供了各种各样的数据可视化要诀和技巧，这些可以使你更上一层楼。&lt;/p&gt;

&lt;h2 id=&quot;商业知识&quot;&gt;商业知识&lt;/h2&gt;
&lt;p&gt;没有背景的数据是没有意义的，你必须明白你正在分析的事情。思路清晰是成为一名数据科学家的关键。&lt;/p&gt;

&lt;p&gt;大多数公司雇佣数据科学家不仅是为了挖掘数据，还需要他们将研究结果传达给各位股东并且提供当即可行的建议。&lt;/p&gt;

&lt;p&gt;最好的数据科学家不但有能力处理大型复杂的数据，也能理解他们为之工作的那些错综复杂的企业或组织。即便是在商业因素的制约下，广泛的业务知识令他们能够提出正确的问题并拿出有见地的建议和切实可行的解决方案。&lt;/p&gt;

&lt;p&gt;资源︰ 这个免费的商业课程列表可以帮助你获得需要的知识。我们的商业数据分析课程也可以帮助你获得这方面的技能。&lt;/p&gt;

&lt;h2 id=&quot;领域专长&quot;&gt;领域专长&lt;/h2&gt;
&lt;p&gt;作为一名数据科学家，你应该了解自己所做的事情以及它所处的行业。&lt;/p&gt;

&lt;p&gt;除了深入了解你为之工作的公司，你也需要了解整个领域来培养商业洞察力。来自于生物学研究的数据和来自心理学实验的数据很可能有截然不同的背景，你应该对那些行业术语有足够多的了解。&lt;/p&gt;

&lt;p&gt;资源︰ 这在很大程度上具有行业依赖性，你必须找到你自己的方式并且尽可能多的学习和你行业相关的内容 ！&lt;/p&gt;

&lt;h2 id=&quot;分析思维&quot;&gt;分析思维&lt;/h2&gt;
&lt;p&gt;想在数据科学领域做好，你需要严谨的分析思维。大量的数据科学在解决问题时都需要有一个敏锐的头脑。&lt;/p&gt;

&lt;p&gt;资源︰ 通过书和难题来保持你的头脑敏锐。类似于Lumosity 这样的网站可以帮助你在任何时刻都保持敏锐的认知能力。&lt;/p&gt;

&lt;hr /&gt;
&lt;h1 id=&quot;数据科学工具&quot;&gt;数据科学工具&lt;/h1&gt;
&lt;p&gt;随着各项技能的完善，现在你需要学会使用现代数据科学工具。每个工具都有其长处和短处，并且每个工具在处理数据的过程中都扮演着不同的角色，你可以使用其中之一或者全部。下面是数据科学中最流行的工具以及你想要深入了解他们需要用到的资源。&lt;/p&gt;

&lt;h2 id=&quot;文件格式&quot;&gt;文件格式&lt;/h2&gt;
&lt;p&gt;数据可以存储在不同格式的文件中。下面是一些最常见的︰&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;CSV︰ 逗号分隔值。你之前可能用Excel 打开过这种文件。CSV使用分隔符来分割数据，这些分隔符有助于把不同数据点的数据分开。&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;SQL : 结构化查询语言。SQL将数据存储在关联表中。如果把一行数据从右向左读过去，你会得到一个对象的不同数据点 （例如，一个人有年龄、性别和身高等数据类别）。&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;JSON: Javascript对象表示法是人和机器可读的轻量级数据交换格式。来自 web 服务器的数据通常用这种格式进行传输。&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;excel&quot;&gt;EXCEL&lt;/h2&gt;
&lt;p&gt;简介︰ Excel往往是通往数据科学的入口，从某种意义上讲每个数据科学家都能从学习它的过程中受益。&lt;/p&gt;

&lt;p&gt;Excel允许你所见即所得的轻松处理数据，你可以对数据进行方程计算而完全不需要使用代码。它对那些想不通过编程而得到结果的数据分析师来说是一个非常方便的工具。&lt;/p&gt;

&lt;p&gt;Excel非常容易上手，这个程序可以让任何人在分析中有直观的理解。你和不具备任何编程技能的人进行数据沟通时，Excel都是非常有用的工具，因为这些人仍然能对数据进行处理。&lt;/p&gt;

&lt;p&gt;谁在使用︰数据分析师倾向于使用 Excel。&lt;/p&gt;

&lt;p&gt;难易程度：初级&lt;/p&gt;

&lt;p&gt;示例项目︰尝试导入一个NBA 球员的小型数据集并制作简单的图表展示联赛中的高得分球员。&lt;/p&gt;

&lt;h2 id=&quot;sql&quot;&gt;SQL&lt;/h2&gt;
&lt;p&gt;简介︰SQL是最流行的用于查找数据的编程语言。&lt;/p&gt;

&lt;p&gt;数据科学当然需要数据，而SQL正是一种专门用于从数据库中提取数据的编程语言。
SQL 是数据科学家中最流行的工具。世界上的大部分数据存储在需要用SQL来访问的表格中。你可以通过SQL对数据进行筛选和排序。&lt;/p&gt;

&lt;p&gt;谁在使用︰数据分析师和一些数据工程师倾向于使用SQL。&lt;/p&gt;

&lt;p&gt;难度等级︰初级&lt;/p&gt;

&lt;p&gt;示例项目︰尝试使用SQL从 Billboard 100的榜单中查询最流行的十大歌曲。&lt;/p&gt;

&lt;h2 id=&quot;python&quot;&gt;PYTHON&lt;/h2&gt;
&lt;p&gt;简介：Python 是数据科学中一种功能强大且用途广泛的编程语言。&lt;/p&gt;

&lt;p&gt;一旦你下载好Rodeo (一种Python IDE），你很快就会发现Python 究竟有多直观 。作为一种可以从开发网站到跨网络收集数据的多功能编程语言，Python 有很多致力于使数据科学工作更加简单的代码库。&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    记住，Python 是一门语法简单的多功能编程语言，很容易学习。

    Python程序猿在这个网站的调查中平均年薪是$102,000，而Python目前是大学教学中最流行的编程语言，Python社区对于Python教学也充满热情并且开发了很多有用的工具，这都会节省你的时间从而让你有更多的精力来分析数据。

    许多数据科学家都在使用Python解决他们的问题︰ 在O&apos;Reilly的一项调查中，40%的受访者在明确的数据科学研究中使用Python，而使用Excel的人是36%。

    谁在使用︰ 数据工程师和数据科学家将使用Python来处理中等规模数据集。

    难度等级︰ 中级

    示例项目︰ 使用 Python 来获取名人的tweets，然后分析他们使用最频繁的一个词。
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;r&quot;&gt;R&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    简介︰ R是数据科学界的一门主要语言，因为它是明确地根据数据科学的需求而设计的。在数据科学界，R是最流行的编程环境，超过43%的专业人员都在使用R语言。

    R是一个专门为数据分析而设计的编程环境，当你需要建立统计模型和进行结果展示时，R会大放异彩。它可以适用于各种各样的统计和图形技术。

    类似于 Python，R社区成员贡献了各种各样可以扩展R代码库核心功能的包，这些包可以应用于一些特定的问题，如测量财务指标或分析气候数据。
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;谁在使用︰数据工程师和数据科学家使用R处理中等规模的数据集。&lt;/p&gt;

&lt;p&gt;难度等级︰ 中级&lt;/p&gt;

&lt;p&gt;示例项目︰ 使用 R来展示过去五年的股票市场走势。&lt;/p&gt;

&lt;hr /&gt;
&lt;h1 id=&quot;大数据工具&quot;&gt;大数据工具&lt;/h1&gt;
&lt;p&gt;大数据来自于摩尔定律，即计算机的计算能力每两年就会翻一倍。这使得数以百万计的计算机生成大规模数据集。想象一下Facebook 在任何一个特定时间能生成多少数据吧！&lt;/p&gt;

&lt;p&gt;根据麦肯锡的调查，任何一个使用SQL和Excel等常规数据工具无法完成分析的数据集都可以说是大数据。最简单的定义就是，大数据并不适合在你自己的计算机上进行处理。&lt;/p&gt;

&lt;p&gt;下面是解决这一问题的一些工具︰&lt;/p&gt;

&lt;h2 id=&quot;hadoop&quot;&gt;HADOOP&lt;/h2&gt;
&lt;p&gt;简介︰通过使用 Hadoop，你只需要通过一个服务器就可以控制存储在多个服务器的数据。&lt;/p&gt;

&lt;p&gt;这种解决方案是一种叫做 MapReduce 的技术。MapReduce 是一个抽象的概念，它把一系列计算机当作一个中央服务器。这就允许你将数据存储在多台计算机，仅通过其中一台对数据进行处理。Hadoop 则是开源生态系统的工具，它允许你在不同的服务器上存储庞大的数据集，也允许你在一台计算机上管理多个数据集。&lt;/p&gt;

&lt;p&gt;谁在使用︰数据工程师和数据科学家会使用 Hadoop 来处理大规模的数据集。&lt;/p&gt;

&lt;p&gt;难度等级︰ 高级&lt;/p&gt;

&lt;p&gt;示例项目︰ 利用 Hadoop 将大规模数据集进行实时更新，例如Facebook 用户生成的赞的数目 。&lt;/p&gt;

&lt;h2 id=&quot;nosql&quot;&gt;NOSQL&lt;/h2&gt;
&lt;p&gt;简介︰ NoSQL 允许您管理数据而无需不必要的负担。&lt;/p&gt;

&lt;p&gt;囊括所有数据的表格可能会非常笨重。NoSQL 包括许多数据存储方案，可以将巨大的数据集分离成易于管理的数据块。&lt;/p&gt;

&lt;p&gt;NoSQL 是由谷歌引领的一种趋势，google用它来处理自己存储的那些难以想象的大数据。NoSQL经常以 web 开发人员欢迎的JSON 格式进行数据结构化，类似于MongoDB 这样的解决方案已经创建了可以用类似SQL处理的数据库，这些数据库可以用更小的结构和密度来存储数据。&lt;/p&gt;

&lt;p&gt;谁在使用︰ 数据工程师和数据科学家使用 NoSQL 来处理大型数据集，通常是那些有百万计用户的数据库网站。&lt;/p&gt;

&lt;p&gt;难度等级︰ 高级&lt;/p&gt;

&lt;p&gt;示例项目︰ 存储部署在web上的社交媒体的用户数据。&lt;/p&gt;

&lt;hr /&gt;
&lt;h1 id=&quot;联系起来-数据处理过程中的工具&quot;&gt;联系起来︰ 数据处理过程中的工具&lt;/h1&gt;
&lt;p&gt;我们已经介绍过的每一款工具都是可以互补的，且有自己的长处和短处。而每一款工具也都可以应用于数据处理过程的不同阶段。&lt;/p&gt;

&lt;p&gt;image https://vip.biotrainee.com/assets/images/3-BSTQFEYmLtvEvmwP.png&lt;/p&gt;

&lt;h2 id=&quot;数据收集&quot;&gt;数据收集&lt;/h2&gt;
&lt;p&gt;有时数据分析不是难事，难的是找到你需要的数据。不过好在我们有很多资源。&lt;/p&gt;

&lt;p&gt;你可以通过所谓的API（应用程序接口，Application Programming Interface）来创建你想要的数据集。API允许你从某些数据提供商那里获取结构化的数据。比如你能从Twitter、Facebook 和 Instagram 查询各种各样的数据。&lt;/p&gt;

&lt;p&gt;如果你想要处理公共数据，美国政府已经将其中一部分免费向所有人开放，Reddit就追踪了其中最受欢迎的数据集。数据搜索引擎 Quandl 则可以用来搜索最匹配的数据。&lt;/p&gt;

&lt;p&gt;我们的博客也列出了19个我们最喜爱的公共数据集，当你马上就需要好数据的时候它可以帮上你。
如果你就是想找点没那么严肃死板的东西，看看这篇博客吧，其中竟然包括了信鸽比赛 ！&lt;/p&gt;

&lt;p&gt;Python 支持大多数的数据格式。你可以处理CSV数据或来自 web 的 JSON数据，当然，你也可以把SQL表直接导入到你的代码 。
你还可以从 web 创建数据集，Python 的requests 库让你可以运行一行代码就从不同的网站获取数据。你可以先从维基百科的列表中获取数据，然后用beautifulsoup 库清洗数据，随后便可以进行深入的分析了。&lt;/p&gt;

&lt;p&gt;R可以从Excel、CSV和其它文本格式文件中获取数据。Minitab或SPSS 格式的文件也可以转换为R的数组。
在R中，你可以使用Rvest包进行基本的网络数据爬取，magrittr包则可以用来进行数据的清洗和分析。这些包和Python 中的requests库和beautifulsoup库类似。&lt;/p&gt;

&lt;h2 id=&quot;数据处理&quot;&gt;数据处理&lt;/h2&gt;
&lt;p&gt;Excel可以让你通过菜单轻松地清洗数据，例如删除重复值、按列筛选排序或者删除行和列的数据。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL&lt;/strong&gt;具有基本的筛选和排序功能，因此你可以准确地获取自己需要的数据。当然，你也还可以随时更新SQL表和或者删除其中的某些值。&lt;/p&gt;

&lt;p&gt;Python则可以使用Pandas库进行数据分析。与Excel相比，它处理大型数据集的速度更快且功能更多。你可以通过编程的方法来使用Pandas库，例如，通过一行代码将数据集的所有错误值替换为某些默认值，例如0。&lt;/p&gt;

&lt;p&gt;R可以帮助你在信息中添加列、改变数据结构或者进行数据本身的转换。很多新的R语言包，如reshape2，可以让你处理各种各样的数据框使它们符合你所设定的标准。&lt;/p&gt;

&lt;p&gt;NoSQL允许你提取大型数据集的子集并依据自己的意愿更改数据，你也可以借助这些功能清洗数据。&lt;/p&gt;

&lt;h2 id=&quot;探索性分析&quot;&gt;探索性分析&lt;/h2&gt;
&lt;p&gt;Excel可以进行列求和、均值计算，也可以借助漂亮的方程进行基础的统计和数值分析。&lt;/p&gt;

&lt;p&gt;Python和pandas可以对数据进行更加复杂的分析从而让你轻松发现更高级的趋势。&lt;/p&gt;

&lt;p&gt;在Pandas中你能够做深入的时序分析，比如跟踪股票价格的变化。&lt;/p&gt;

&lt;p&gt;R语言设计的初衷就是进行大型数据集的统计和数值分析。你可以构建概率分布、对数据进行各种统计检验，也可以进行机器学习和数据挖掘。&lt;/p&gt;

&lt;p&gt;而NoSQL 和 Hadoop 都允许你在SQL这一层级上进行探索性的数据分析。&lt;/p&gt;

&lt;h2 id=&quot;数据分析&quot;&gt;数据分析&lt;/h2&gt;
&lt;p&gt;Excel 对数据进行高层次的分析，使用数据透视表可以动态的展示数据，使用高级公式和宏编程可以让你以编程的方式来分析数据。&lt;/p&gt;

&lt;p&gt;Python 则提供了数据分析库Numpy。你可以通过SciPy进行科学计算与计算或者通过scikit-learn代码库获取大量已经预构建的机器学习算法。&lt;/p&gt;

&lt;p&gt;R有大量的包供你进行各种特定分析，比如泊松分布和混合概率。&lt;/p&gt;

&lt;h2 id=&quot;数据呈现&quot;&gt;数据呈现&lt;/h2&gt;
&lt;p&gt;Excel 具有基本的图表和绘图功能。你可以轻松构建仪表板和可以进行数据实时更新的动态图表。&lt;/p&gt;

&lt;p&gt;在数据可视化方面，Python 有很多非常强大的选择。你可以使用 Matplotlib 库将 Python 中的数据生成基本的图表。如果你想要更高级的东西，可以试试 Plot.ly 和它的Python API。&lt;/p&gt;

&lt;p&gt;除此以外，你也可以使用 nbconvert 函数将你的Python 笔记变成 HTML 文档。这样你就可以把代码块嵌入到交互网站或你的项目档案中。有很多人使用这个函数来写Python学习的在线教程。&lt;/p&gt;

&lt;p&gt;R是用来做统计分析和结果展示的。因为R中有很多专门的包可以用来做各种类型的图表结果展示，因此它是一个非常适合用来做科学可视化的强大开发环境。你可以用基本图形模块从数据矩阵中构造所有你想要的基本表格和图形，然后把这些文件保存为.jpg等图像格式或者保存为单独的pdf，你也可以使用ggplot2中更加高级的图表，比如带有回归线的散点图。&lt;/p&gt;

&lt;hr /&gt;
&lt;h1 id=&quot;开始求职&quot;&gt;开始求职&lt;/h1&gt;
&lt;p&gt;你已经了解了入门数据科学和成为数据科学家所需要的技能和工具，现在是将这些理论应用到寻找一份数据科学工作的时候了。&lt;/p&gt;

&lt;h2 id=&quot;构建数据科学项目集和简历&quot;&gt;构建数据科学项目集和简历&lt;/h2&gt;
&lt;p&gt;你需要为自己进入数据科学领域提供一个不错的第一印象——那就是项目集和简历。许多数据科学家都有自己的网站，里面既有和工作相关的项目集也有展示自己想法的博客。&lt;/p&gt;

&lt;p&gt;这些网站使他们能够展示自己的经历和在数据科学领域创造的价值。为了使你自己的项目档案也具有相同的效果，它必须具有以下特点：&lt;/p&gt;

&lt;p&gt;你的项目集应该突出自己最棒的项目。专注于几个令人难忘的项目通常比展示大量平淡无奇的项目更好。
它必须经过精心设计并且要有一个迷人的故事，让大家了解你是谁而非仅仅是你的工作。
你应该通过突出自己在工作中的创造的影响力来为你的访问者创造价值。也许你开发了一个对大家有用的工具？也许你有一个教程？把它们在这里展示出来。
应该很容易找到你的联系信息。
例如，你可以看看我们网站导师 Sundeep Pattem 的个人项目集中的几个项目。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Sundeep Pattem 致力于研究和实际生活联系紧密的复杂数据问题。他有五个项目分别涉及医疗成本、劳动力市场、可持续能源、在线教育和世界经济。这些领域中每一个都有大量的数据问题需要解决。这些项目都独立于任何真正意义上的工作，它们表明Sundeep是发自内心地喜欢为那些复杂的数据科学问题提供解决方案。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;如果缺乏想法，你可以参加数据科学竞赛。类似于Kaggle，Datakind和Datadriven这样的平台允许你去解决真实的企业或社会问题。通过利用数据科学技术，你可以展示自己的影响价值，创造出最有说服力的项目集，向别人证明自己的执行力。&lt;/p&gt;

&lt;h2 id=&quot;在哪里找工作&quot;&gt;在哪里找工作&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Kaggle 为数据科学家提供了一个 工作公告栏。
你可以在工作搜索引擎Indeed 中找到一系列公开的数据科学工作招聘信息。&lt;/li&gt;
  &lt;li&gt;Datajobs提供了一个数据科学网站清单，这是一个学习如何成为数据科学家的好地方。
你也可以通过人际交往或者联系导师来寻找机会。我们再一次强调，最好的工作岗位往往是通过与数据科学界人士交流而找到的。这就是你成为一名数据科学家的方式。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;你还可以在很多创业论坛找到就业机会。Hacker News有一个专门属于Y Combinator（也许是世界上最著名的创业孵化器）的工作公告栏。Angellist是一个为初创公司寻求资金的数据库，它也有工作板块。&lt;/p&gt;

&lt;h2 id=&quot;数据科学面试宝典&quot;&gt;数据科学面试宝典&lt;/h2&gt;
&lt;p&gt;有关数据科学面试的内容可以写成一本书，事实上，我们就是这么做的！&lt;/p&gt;

&lt;p&gt;如果你得到了面试机会，接下来该做什么呢？在数据科学面试中有这么几类常见的问题：个人背景、编程问题和机器学习应用问题。你应该预料到在任何一场数据科学面试中都会有技术性和非技术性的问题。首先确保复习一下编程和数据科学相关的知识，然后尝试把它们与你自己的故事融合在一起！&lt;/p&gt;

&lt;p&gt;通常你还会被要求分析一些数据，也很可能被问及文化契合和统计学问题。为了准备编程相关的问题，在某种程度上，你必须将数据科学面试看作一次软件工程训练。你应该复习一下所有的编程面试资源，其中大部分都是在线的。这个列表是你可能会遇到的数据科学问题。&lt;/p&gt;

&lt;h3 id=&quot;你会看到几类常见问题&quot;&gt;你会看到几类常见问题：&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Python 和 R：在某种情况下你更喜欢哪种语言？&lt;/li&gt;
  &lt;li&gt;什么是K-means（一类特殊的数据科学算法）？请描述一下使用它的场景。&lt;/li&gt;
  &lt;li&gt;给我们讲讲你最近参与的一个数据科学项目。&lt;/li&gt;
  &lt;li&gt;你对我们业务增长的关键驱动因素有什么了解？
第一类问题测试你的编程知识；第二类问题测试你对算法的了解，并请你分享自己的实际使用经验；第三个问题则是深入了解你以前的数据科学工作；最后，第四类问题将测试你对面试企业的了解程度。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;如果你能展示自己的数据科学工作帮助潜在雇主的受益方式，那会给他们留下深刻的印象。这样，他们才能知道，你在关注公司的工作内容，并且对这个行业有着充分的了解，也无需进行入职教育。&lt;/p&gt;

&lt;p&gt;以上，就是一名数据科学家的成长之路。
&lt;a href=&quot;http://kaopubear.top/2017-02-22/2017-02-22-BecomingADataScientist/&quot;&gt;博客原文链接&lt;/a&gt;&lt;/p&gt;

</description>
        <pubDate>Sun, 05 May 2019 12:43:45 +0000</pubDate>
        <link>https://liuxm0239.github.io/2019/05/05/Data-Science/</link>
        <guid isPermaLink="true">https://liuxm0239.github.io/2019/05/05/Data-Science/</guid>
        
        <category>统计学习方法</category>
        
        
        <category>统计学习</category>
        
      </item>
    
      <item>
        <title>Cloud Platform for Genomics</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#forum-list-of-cloud-genomics-companies&quot; id=&quot;markdown-toc-forum-list-of-cloud-genomics-companies&quot;&gt;&lt;strong&gt;Forum: List Of Cloud Genomics Companies&lt;/strong&gt;&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#1-seven-bridges-genomics-httpwwwsbgenomicscom&quot; id=&quot;markdown-toc-1-seven-bridges-genomics-httpwwwsbgenomicscom&quot;&gt;1. Seven Bridges Genomics – http://www.sbgenomics.com&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#11-概述&quot; id=&quot;markdown-toc-11-概述&quot;&gt;1.1 概述：&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#11-收费标准&quot; id=&quot;markdown-toc-11-收费标准&quot;&gt;1.1 收费标准：&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#12-使用案例&quot; id=&quot;markdown-toc-12-使用案例&quot;&gt;1.2 使用案例&lt;/a&gt;            &lt;ul&gt;
              &lt;li&gt;&lt;a href=&quot;#121--全外显子分析每个样品花费约1&quot; id=&quot;markdown-toc-121--全外显子分析每个样品花费约1&quot;&gt;1.2.1  全外显子分析，每个样品花费约$1。&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=&quot;#122-sentieon-wgs-50x-samples数据30x-全基因组约687&quot; id=&quot;markdown-toc-122-sentieon-wgs-50x-samples数据30x-全基因组约687&quot;&gt;1.2.2 Sentieon WGS 50x samples数据，30X 全基因组约$6.87.&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#2-basespace-httpbasespaceilluminacom&quot; id=&quot;markdown-toc-2-basespace-httpbasespaceilluminacom&quot;&gt;2. BaseSpace – http://basespace.illumina.com&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#21-概述有部署edico-genomics流程分析速度快仅支持illumina平台数据与illumina测序仪对接方便但其他来源数据上传很麻烦&quot; id=&quot;markdown-toc-21-概述有部署edico-genomics流程分析速度快仅支持illumina平台数据与illumina测序仪对接方便但其他来源数据上传很麻烦&quot;&gt;2.1 概述：有部署edico genomics流程，分析速度快；仅支持illumina平台数据，与illumina测序仪对接方便，但其他来源数据上传很麻烦。&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#21-收费标准&quot; id=&quot;markdown-toc-21-收费标准&quot;&gt;2.1 收费标准：&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#22-使用案例&quot; id=&quot;markdown-toc-22-使用案例&quot;&gt;2.2 使用案例&lt;/a&gt;            &lt;ul&gt;
              &lt;li&gt;&lt;a href=&quot;#221-肿瘤配对样品体细胞突变检测流程全基因组数据2100x500g数据量&quot; id=&quot;markdown-toc-221-肿瘤配对样品体细胞突变检测流程全基因组数据2100x500g数据量&quot;&gt;2.2.1 肿瘤配对样品体细胞突变检测流程，全基因组数据2*100X，500G数据量&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=&quot;#222-种系突变流程全外显子数据2225x14g数据量&quot; id=&quot;markdown-toc-222-种系突变流程全外显子数据2225x14g数据量&quot;&gt;2.2.2 种系突变流程，全外显子数据2*225X，14G数据量&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=&quot;#222-16s-宏基因组分析15个样品7m-reads&quot; id=&quot;markdown-toc-222-16s-宏基因组分析15个样品7m-reads&quot;&gt;2.2.2 16S 宏基因组分析，15个样品，7M reads&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=&quot;#223-edico-genome-on-aws&quot; id=&quot;markdown-toc-223-edico-genome-on-aws&quot;&gt;2.2.3 Edico Genome on AWS&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#3-dnanexus-httpdnanexuscom&quot; id=&quot;markdown-toc-3-dnanexus-httpdnanexuscom&quot;&gt;3. DNAnexus – http://dnanexus.com&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#31-概述个性化支持较好cwl--dwl&quot; id=&quot;markdown-toc-31-概述个性化支持较好cwl--dwl&quot;&gt;3.1 概述：个性化支持较好（CWL &amp;amp; DWL）&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#4-insidednahttpinsidedname&quot; id=&quot;markdown-toc-4-insidednahttpinsidedname&quot;&gt;4. InsideDNA http://insidedna.me/&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#41-概述部署在gcp上-提供咨询服务提供集群租用模式使用cli&quot; id=&quot;markdown-toc-41-概述部署在gcp上-提供咨询服务提供集群租用模式使用cli&quot;&gt;4.1 概述：部署在GCP上， 提供咨询服务，提供集群租用模式（使用CLI）&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#41-收费标准&quot; id=&quot;markdown-toc-41-收费标准&quot;&gt;4.1 收费标准：&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#5-curoversehttpcuroversecom&quot; id=&quot;markdown-toc-5-curoversehttpcuroversecom&quot;&gt;5. Curoverse http://curoverse.com&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#6-pine-biotechhttppine-biotechcom&quot; id=&quot;markdown-toc-6-pine-biotechhttppine-biotechcom&quot;&gt;6. Pine Biotech http://pine-biotech.com/&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#7-broad-firecloud-httpsgatkforumsbroadinstituteorgfirecloud&quot; id=&quot;markdown-toc-7-broad-firecloud-httpsgatkforumsbroadinstituteorgfirecloud&quot;&gt;7. Broad firecloud https://gatkforums.broadinstitute.org/firecloud/&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#71-案例-全基因组每个-5-&quot; id=&quot;markdown-toc-71-案例-全基因组每个-5-&quot;&gt;7.1 案例： 全基因组每个 $5 &lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;

&lt;h2 id=&quot;forum-list-of-cloud-genomics-companies&quot;&gt;&lt;a href=&quot;https://www.biostars.org/p/86463/&quot;&gt;&lt;strong&gt;Forum: List Of Cloud Genomics Companies&lt;/strong&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;h3 id=&quot;1-seven-bridges-genomics-httpwwwsbgenomicscom&quot;&gt;1. Seven Bridges Genomics – &lt;a href=&quot;http://www.sbgenomics.com/&quot;&gt;http://www.sbgenomics.com&lt;/a&gt;&lt;/h3&gt;

&lt;h4 id=&quot;11-概述&quot;&gt;1.1 概述：&lt;/h4&gt;

&lt;p&gt;分析流程多（有部署Sentieon流程），个性化支持较好（支持CWL），用户仅承担云平台使用费用。&lt;/p&gt;

&lt;h4 id=&quot;11-收费标准&quot;&gt;1.1 收费标准：&lt;/h4&gt;

&lt;p&gt;Seven Bridges Genomics的流程部署在AWS(或AWS-EU)和GCP上，&lt;a href=&quot;https://docs.sevenbridges.com/page/faqs&quot;&gt;费用：仅收取云平台使用成本价，不附加其他费用。（AWS or GCP，计价以使用平台的计价规则为准）&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;12-使用案例&quot;&gt;1.2 使用案例&lt;/h4&gt;

&lt;h5 id=&quot;121--全外显子分析每个样品花费约1&quot;&gt;1.2.1  全外显子分析，每个样品花费约$1。&lt;/h5&gt;

&lt;p&gt;每个账户有$100的试用金额，可以完成30个30X外显子测序数据的分析，平均一个花费约$1.(从fastq到突变，使用BWA-GATK流程分析)&lt;/p&gt;

&lt;h5 id=&quot;122-sentieon-wgs-50x-samples数据30x-全基因组约687&quot;&gt;1.2.2 Sentieon WGS 50x samples数据，30X 全基因组约$6.87.&lt;/h5&gt;

&lt;p&gt;&lt;img src=&quot;https://upload-images.jianshu.io/upload_images/8533342-158a0d7328b706ea.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240&quot; alt=&quot;Sentieon WGS 50x samples&quot; /&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;2-basespace-httpbasespaceilluminacom&quot;&gt;2. BaseSpace – &lt;a href=&quot;http://basespace.illumina.com/&quot;&gt;http://basespace.illumina.com&lt;/a&gt;&lt;/h3&gt;

&lt;h4 id=&quot;21-概述有部署edico-genomics流程分析速度快仅支持illumina平台数据与illumina测序仪对接方便但其他来源数据上传很麻烦&quot;&gt;2.1 概述：有部署edico genomics流程，分析速度快；仅支持illumina平台数据，与illumina测序仪对接方便，但其他来源数据上传很麻烦。&lt;/h4&gt;

&lt;h4 id=&quot;21-收费标准&quot;&gt;2.1 收费标准：&lt;/h4&gt;

&lt;p&gt;a，计算费用：流程按使用时间计费，不同流程单价不同；
b，存储费用：每个用户有1T免费存储费用，超出部分每Gb数据每月费用$0.03.&lt;/p&gt;

&lt;h4 id=&quot;22-使用案例&quot;&gt;2.2 使用案例&lt;/h4&gt;

&lt;h5 id=&quot;221-肿瘤配对样品体细胞突变检测流程全基因组数据2100x500g数据量&quot;&gt;2.2.1 肿瘤配对样品体细胞突变检测流程，全基因组数据2*100X，500G数据量&lt;/h5&gt;

&lt;p&gt;使用DRAGEN Somatic 流程，流程单价每小时$4.98，耗时约5小时，总费用$24.&lt;/p&gt;

&lt;h5 id=&quot;222-种系突变流程全外显子数据2225x14g数据量&quot;&gt;2.2.2 种系突变流程，全外显子数据2*225X，14G数据量&lt;/h5&gt;

&lt;p&gt;使用DRAGEN Germline 流程，流程单价每小时$4.98，耗时约12分钟，总费用$2.&lt;/p&gt;

&lt;h5 id=&quot;222-16s-宏基因组分析15个样品7m-reads&quot;&gt;2.2.2 16S 宏基因组分析，15个样品，7M reads&lt;/h5&gt;

&lt;p&gt;分析流程16S Metagenomics ，流程单价每小时$3，耗时3小时15分，总费用$10.&lt;/p&gt;

&lt;h5 id=&quot;223-edico-genome-on-aws&quot;&gt;2.2.3 &lt;a href=&quot;https://aws.amazon.com/marketplace/pp/B07CZ3F5HY&quot;&gt;Edico Genome on AWS&lt;/a&gt;&lt;/h5&gt;

&lt;p&gt;流程DRAGEN Complete Suite（支持的数据类型有限），不同规格的虚拟机价格不同。平均费用，每个全基因组小于$15, 每个全外显子小于$3.
&lt;strong&gt;Pricing Breakdown:&lt;/strong&gt;
F1.2xlarge: $10.35 (DRAGEN) + $1.65 (Compute) = $12.00/hr
Per Genome: $12.00hr/0.8 genomes = $15
Per Exome: $12.00hr/5.45 exomes = $2
F1.4xlarge: $15.10 (DRAGEN) + $3.30 (Compute) = $18.40/hr
Per Genome: $18.40hr/1.5 genomes = $12.25
Per Exome: $18.40hr/10 exomes = $1.84
F1.16xlarge: $22.10 (DRAGEN) + $13.20 (Compute) = $35.30/hr
Per Genome: $35.30hr/1.76 genomes = $20
Per Exome: $35.30hr/12 exomes = $3&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;3-dnanexus-httpdnanexuscom&quot;&gt;3. DNAnexus – &lt;a href=&quot;http://dnanexus.com/&quot;&gt;http://dnanexus.com&lt;/a&gt;&lt;/h3&gt;

&lt;h4 id=&quot;31-概述个性化支持较好cwl--dwl&quot;&gt;3.1 概述：个性化支持较好（CWL &amp;amp; DWL）&lt;/h4&gt;

&lt;p&gt;&lt;a href=&quot;http://www.bio-itworld.com/2017/08/30/edico-dnanexus-launch-20-90-minute-whole-genome-analysis.asp&quot;&gt;Edico, DNAnexus Launch $20, 90-minute Whole Genome Analysis：2017/08&lt;/a&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;4-insidednahttpinsidedname&quot;&gt;4. InsideDNA &lt;a href=&quot;http://insidedna.me/&quot;&gt;http://insidedna.me/&lt;/a&gt;&lt;/h3&gt;

&lt;h4 id=&quot;41-概述部署在gcp上-提供咨询服务提供集群租用模式使用cli&quot;&gt;4.1 概述：部署在GCP上， 提供咨询服务，提供集群租用模式（使用CLI）&lt;/h4&gt;

&lt;h4 id=&quot;41-收费标准&quot;&gt;4.1 &lt;a href=&quot;https://insidedna.io/pricing&quot;&gt;收费标准&lt;/a&gt;：&lt;/h4&gt;

&lt;p&gt;a, 计算费用：谷歌云收费基础上+ 25%
b, 存储费用：&lt;strong&gt;个人&lt;/strong&gt; 10TB，$45每月；&lt;strong&gt;团队&lt;/strong&gt; 50TB ，5人，$225每月&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;5-curoversehttpcuroversecom&quot;&gt;5. Curoverse &lt;a href=&quot;http://curoverse.com/&quot;&gt;http://curoverse.com&lt;/a&gt;&lt;/h3&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;6-pine-biotechhttppine-biotechcom&quot;&gt;6. Pine Biotech &lt;a href=&quot;http://pine-biotech.com/&quot;&gt;http://pine-biotech.com/&lt;/a&gt;&lt;/h3&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;7-broad-firecloud-httpsgatkforumsbroadinstituteorgfirecloud&quot;&gt;7. Broad firecloud &lt;a href=&quot;https://gatkforums.broadinstitute.org/firecloud/&quot;&gt;https://gatkforums.broadinstitute.org/firecloud/&lt;/a&gt;&lt;/h3&gt;

&lt;h4 id=&quot;71-案例-全基因组每个-5-&quot;&gt;7.1 案例： &lt;a href=&quot;https://software.broadinstitute.org/gatk/blog?id=11415&quot;&gt;全基因组每个 $5 &lt;/a&gt;&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;-&lt;/th&gt;
      &lt;th&gt;2016&lt;/th&gt;
      &lt;th&gt;2017&lt;/th&gt;
      &lt;th&gt;201802&lt;/th&gt;
      &lt;th&gt; &lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;no. of Whole Genomes Analyzed&lt;/td&gt;
      &lt;td&gt;900&lt;/td&gt;
      &lt;td&gt;900&lt;/td&gt;
      &lt;td&gt;900&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Total Compute Cost&lt;/td&gt;
      &lt;td&gt;$40,500&lt;/td&gt;
      &lt;td&gt;$12,150&lt;/td&gt;
      &lt;td&gt;$4,500&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Cost per Genome Analyzed&lt;/td&gt;
      &lt;td&gt;$45&lt;/td&gt;
      &lt;td&gt;$13.50&lt;/td&gt;
      &lt;td&gt;$5&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
</description>
        <pubDate>Fri, 08 Mar 2019 03:38:45 +0000</pubDate>
        <link>https://liuxm0239.github.io/2019/03/08/Market/</link>
        <guid isPermaLink="true">https://liuxm0239.github.io/2019/03/08/Market/</guid>
        
        <category>云平台</category>
        
        
        <category>市场</category>
        
      </item>
    
      <item>
        <title>Bismark: paired-end low mapping efficiency</title>
        <description>&lt;hr /&gt;

&lt;p&gt;测试中发现有一批甲基化数据的比对率非常低，&lt;/p&gt;

&lt;p&gt;模拟数据的问题，下载的数据比对正常（SRR5343780） &lt;a href=&quot;http://seqanswers.com/forums/showthread.php?t=40496&quot;&gt;Bismark: paired-end low mapping efficiency&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;–min_score L,0,-1.9 可以解决；（-1.9允许比对中存在跟多的 mismatch；–score_min L,0,-0.2 将允许 100bp 读取的 ~3 个错配，–score_min L,0,-0.6 将允许最多 10 个错配和/或 Indel）&lt;/li&gt;
  &lt;li&gt;排除质量值分布问题（trim-glaore；fastqc正常）；&lt;/li&gt;
  &lt;li&gt;排除 reads 顺序不一致问题；&lt;/li&gt;
  &lt;li&gt;排除 reference 用错；&lt;/li&gt;
  &lt;li&gt;排除 directionial/non-dicret 文库问题&lt;/li&gt;
&lt;/ol&gt;
</description>
        <pubDate>Sun, 03 Mar 2019 02:16:27 +0000</pubDate>
        <link>https://liuxm0239.github.io/2019/03/03/Bismark_pe_low_map_effecient/</link>
        <guid isPermaLink="true">https://liuxm0239.github.io/2019/03/03/Bismark_pe_low_map_effecient/</guid>
        
        <category>表观遗传学</category>
        
        <category>Bioinfo</category>
        
        
        <category>生物信息</category>
        
        <category>计算方法</category>
        
      </item>
    
      <item>
        <title>Zcat adds .Z in Mac OS(re-print)</title>
        <description>&lt;hr /&gt;

&lt;p&gt;&lt;a href=&quot;https://magnatecha.com/zcat-adds-z-in-mac-os/&quot;&gt;original&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Zcat is a great tool to output the contents of a gzipped file. You can use it to do snazzy things like pipe a gzipped database archive into mysql without waiting for it to decompress to a normal file first. Coming from Linux, you might just think that Mac OS is similar enough to whip out zcat and go to town. Unfortunately, Mac OS’s zcat tries to append “.Z” to the file argument, and you get something like “thatfile.gz.Z doesn’t exist”. I’m guessing this has something to do with Mac OS’s BSDness, but it doesn’t really matter.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;To avoid this behaviour, just use gzcat! Gzcat has all the goodness of zcat, but doesn’t try to append “.Z”.
gzcat yourfile.gz&lt;/p&gt;
&lt;/blockquote&gt;
</description>
        <pubDate>Sun, 03 Mar 2019 01:46:45 +0000</pubDate>
        <link>https://liuxm0239.github.io/2019/03/03/Zcat_adds_.Z_in_Mac_OS/</link>
        <guid isPermaLink="true">https://liuxm0239.github.io/2019/03/03/Zcat_adds_.Z_in_Mac_OS/</guid>
        
        <category>Macos</category>
        
        
        <category>操作系统强迫症</category>
        
      </item>
    
      <item>
        <title>Python argparse</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#参考资料&quot; id=&quot;markdown-toc-参考资料&quot;&gt;参考资料&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;

&lt;p&gt;#&lt;a href=&quot;http://wiki.jikexueyuan.com/project/explore-python/Standard-Modules/argparse.html&quot;&gt;argparse(reprint)&lt;/a&gt;
argparse 是 Python 内置的一个用于命令项选项与参数解析的模块，通过在程序中定义好我们需要的参数，argparse 将会从 sys.argv 中解析出这些参数，并自动生成帮助和使用信息。当然，Python 也有第三方的库可用于命令行解析，而且功能也更加强大，比如 docopt，Click。&lt;/p&gt;

&lt;p&gt;##argparse 使用
###简单示例
我们先来看一个简单示例。主要有三个步骤：
创建 ArgumentParser() 对象
调用 add_argument() 方法添加参数
使用 parse_args() 解析添加的参数&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# -*- coding: utf-8 -*-

import argparse

parser = argparse.ArgumentParser()
parser.add_argument(&apos;integer&apos;, type=int, help=&apos;display an integer&apos;)
args = parser.parse_args()

print args.integer
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;将上面的代码保存为文件 argparse_usage.py，在终端运行，结果如下：&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ python argparse_usage.py
usage: argparse_usage.py [-h] integer
argparse_usage.py: error: too few arguments

$ python argparse_usage.py abcd
usage: argparse_usage.py [-h] integer
argparse_usage.py: error: argument integer: invalid int value: &apos;abcd&apos;

$ python argparse_usage.py -h
usage: argparse_usage.py [-h] integer

positional arguments:
  integer     display an integer

optional arguments:
  -h, --help  show this help message and exit

$ python argparse_usage.py 10
10
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;###定位参数
上面的示例，其实就展示了定位参数的使用，我们再来看一个例子 - 计算一个数的平方：&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# -*- coding: utf-8 -*-

import argparse

parser = argparse.ArgumentParser()
parser.add_argument(&quot;square&quot;, help=&quot;display a square of a given number&quot;, type=int)
args = parser.parse_args()
print args.square**2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;将上面的代码保存为文件 argparse_usage.py，在终端运行，结果如下：&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ python argparse_usage.py 9
81
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;###可选参数
现在看下可选参数的用法，所谓可选参数，也就是命令行参数是可选的，废话少说，看下面例子：&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# -*- coding: utf-8 -*-

import argparse

parser = argparse.ArgumentParser()

parser.add_argument(&quot;--square&quot;, help=&quot;display a square of a given number&quot;, type=int)
parser.add_argument(&quot;--cubic&quot;, help=&quot;display a cubic of a given number&quot;, type=int)

args = parser.parse_args()

if args.square:
    print args.square**2

if args.cubic:
    print args.cubic**3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;将上面的代码保存为文件 argparse_usage.py，在终端运行，结果如下：&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ python argparse_usage.py --h
usage: argparse_usage.py [-h] [--square SQUARE] [--cubic CUBIC]

optional arguments:
  -h, --help       show this help message and exit
  --square SQUARE  display a square of a given number
  --cubic CUBIC    display a cubic of a given number

$ python argparse_usage.py --square 8
64

$ python argparse_usage.py --cubic 8
512

$ python argparse_usage.py 8
usage: argparse_usage.py [-h] [--square SQUARE] [--cubic CUBIC]
argparse_usage.py: error: unrecognized arguments: 8

$ python argparse_usage.py  # 没有输出
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;###混合使用
定位参数和选项参数可以混合使用，看下面一个例子，给一个整数序列，输出它们的和或最大值（默认）：&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;import argparse

parser = argparse.ArgumentParser(description=&apos;Process some integers.&apos;)
parser.add_argument(&apos;integers&apos;, metavar=&apos;N&apos;, type=int, nargs=&apos;+&apos;,
                   help=&apos;an integer for the accumulator&apos;)
parser.add_argument(&apos;--sum&apos;, dest=&apos;accumulate&apos;, action=&apos;store_const&apos;,
                   const=sum, default=max,
                   help=&apos;sum the integers (default: find the max)&apos;)

args = parser.parse_args()
print args.accumulate(args.integers)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;结果：&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ python argparse_usage.py
usage: argparse_usage.py [-h] [--sum] N [N ...]
argparse_usage.py: error: too few arguments
$ python argparse_usage.py 1 2 3 4
4
$ python argparse_usage.py 1 2 3 4 --sum
10
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;add_argument() 方法
add_argument() 方法定义如何解析命令行参数：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;ArgumentParser.add_argument(name or flags…[, action][, nargs][, const][, default][, type][, choices][, required][, help][, metavar][, dest])
每个参数解释如下:&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;name or flags - 选项字符串的名字或者列表，例如 foo 或者 -f, –foo。&lt;/li&gt;
  &lt;li&gt;action - 命令行遇到参数时的动作，默认值是 store。&lt;/li&gt;
  &lt;li&gt;store_const，表示赋值为const；&lt;/li&gt;
  &lt;li&gt;append，将遇到的值存储成列表，也就是如果参数重复则会保存多个值;&lt;/li&gt;
  &lt;li&gt;append_const，将参数规范中定义的一个值保存到一个列表；&lt;/li&gt;
  &lt;li&gt;count，存储遇到的次数；此外，也可以继承 argparse.Action 自定义参数解析；&lt;/li&gt;
  &lt;li&gt;nargs - 应该读取的命令行参数个数，可以是具体的数字，或者是?号，当不指定值时对于 Positional argument 使用 default，对于 Optional argument 使用 const；或者是 * 号，表示 0 或多个参数；或者是 + 号表示 1 或多个参数。&lt;/li&gt;
  &lt;li&gt;const - action 和 nargs 所需要的常量值。&lt;/li&gt;
  &lt;li&gt;default - 不指定参数时的默认值。&lt;/li&gt;
  &lt;li&gt;type - 命令行参数应该被转换成的类型。&lt;/li&gt;
  &lt;li&gt;choices - 参数可允许的值的一个容器。&lt;/li&gt;
  &lt;li&gt;required - 可选参数是否可以省略 (仅针对可选参数)。&lt;/li&gt;
  &lt;li&gt;help - 参数的帮助信息，当指定为 argparse.SUPPRESS 时表示不显示该参数的帮助信息.&lt;/li&gt;
  &lt;li&gt;metavar - 在 usage 说明中的参数名称，对于必选参数默认就是参数名称，对于可选参数默认是全大写的参数名称.&lt;/li&gt;
  &lt;li&gt;dest - 解析后的参数名称，默认情况下，对于可选参数选取最长的名称，中划线转换为下划线.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5 id=&quot;参考资料&quot;&gt;参考资料&lt;/h5&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.python.org/2/howto/argparse.html&quot;&gt;Argparse Tutorial — Python 2.7.12 documentation&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://pymotw.com/2/argparse/&quot;&gt;Argparse – Command line option and argument parsing&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://python.usyiyi.cn/python_278/library/argparse.html&quot;&gt;Argparse — Parser for command-line options, arguments and sub-commands&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://lingxiankong.github.io/blog/2014/01/14/command-line-parser/&quot;&gt;Python 中的命令行解析工具介绍&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Sun, 10 Feb 2019 06:00:45 +0000</pubDate>
        <link>https://liuxm0239.github.io/2019/02/10/Python-argparse/</link>
        <guid isPermaLink="true">https://liuxm0239.github.io/2019/02/10/Python-argparse/</guid>
        
        <category>python</category>
        
        
        <category>编程</category>
        
      </item>
    
      <item>
        <title>Python： lamda, map, filter, reduce</title>
        <description>&lt;hr /&gt;

&lt;p&gt;python zen 函数，python 有很多简洁又功能强大的内置函数，本文介绍其中几个单行函数（含示例代码）
###lambda 简单的单行函数，不可使用return 命令&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mx = lambda x,y: x if x &amp;gt; y else y 
print(mx( 12, 15)) 
15

lst = [i for i in range(1, 11)]

# normal
def sq( lst):
    for i in range(len(lst)):
        lst[i] = lst[i] ** 2
    return lst

print(sq(lst))
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

#generation 
def sq(lst):
    for i in range(len(lst)):
        yield lst[i] ** 2

print(list(sq(lst)))
[1, 16, 81, 256, 625, 1296, 2401, 4096, 6561, 10000]

# lambda 单行函数
print(list(map(lambda x : x**2, lst)))
[1, 16, 81, 256, 625, 1296, 2401, 4096, 6561, 10000]
print([x**2 for x in lst])
[1, 16, 81, 256, 625, 1296, 2401, 4096, 6561, 10000]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;###map，对list 中的每一个元素，应用同一函数 （源自Lisp命令）&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;lst = [i for i in range(1, 11)]
print(list(map(lambda x: x**2, lst)))
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

def sq(x):
    return x**2

print(list(map(sq, lst)))
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;###filter 过滤list 中的元素&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;lst = [i for i in range(1, 11)]
print(list(filter(lambda x: x&amp;gt;2, lst)))
[3, 4, 5, 6, 7, 8, 9, 10]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;###reduce 类似递归 map-reduce?
List, [m, n, p]  ==&amp;gt; Reduce ==&amp;gt; f[f[m, n], p]&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;from functools import reduce
lst = [i for i in range(1, 11)]
print(reduce(lambda x,y: x+y, lst))
55
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Sat, 09 Feb 2019 09:01:45 +0000</pubDate>
        <link>https://liuxm0239.github.io/2019/02/09/Python-lamada-map-etc/</link>
        <guid isPermaLink="true">https://liuxm0239.github.io/2019/02/09/Python-lamada-map-etc/</guid>
        
        <category>python</category>
        
        
        <category>编程</category>
        
      </item>
    
  </channel>
</rss>
