Skip to content

Commit

Permalink
1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
YongxinLiu committed Jul 1, 2023
1 parent 5478aa0 commit 6590d81
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 16 deletions.
Binary file modified linux/fastp
Binary file not shown.
5 changes: 5 additions & 0 deletions script/.Rhistory
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
library(amplicon)
beta_pcoa_stat()
beta_pcoa_stat
setwd("D:/BaiduNetdiskWorkspace/github/EasyMetagenome")
setwd("D:/BaiduNetdiskWorkspace/github/EasyMicrobiome/script")
33 changes: 17 additions & 16 deletions script/compare_volcano.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env Rscript

# Copyright 2016-2020 Yong-Xin Liu <metagenome@126.com>
# Copyright 2016-2023 Yong-Xin Liu <metagenome@126.com>

# If used this script, please cited:
# Jingying Zhang, Yong-Xin Liu, et. al. NRT1.1B is associated with root microbiota composition and nitrogen use in field-grown rice. Nature Biotechnology 37, 676-684, doi:10.1038/s41587-019-0104-4 (2019).
Expand Down Expand Up @@ -118,12 +118,13 @@ main_theme = theme(panel.background = element_blank(),
legend.text = element_text(size = 7),
text = element_text(family = "sans", size = 7))

p =ggplot(diff[diff$log2FC < 4 & diff$log2FC > -4, ], aes(x=log2FC, y=log2CPM, color=level)) +
geom_point(color = "grey")+
# p =ggplot(diff[diff$log2FC < 4 & diff$log2FC > -4, ], aes(x=log2FC, y=log2CPM, color=level)) +
p =ggplot(diff, aes(x=log2FC, y=log2CPM, color=level)) +
geom_point()+scale_colour_manual(values=c("green","red","grey"))+
theme_classic()+
#加抖动
geom_jitter(data = subset(diff, log2FC == 4), width = 0.2, height = 0.2, color = "red")+
geom_jitter(data = subset(diff, log2FC == -4), width = 0.2, height = 0.2, color = "green")+
# geom_jitter(data = subset(diff, log2FC == 4), width = 0.2, height = 0.2, color = "red")+
# geom_jitter(data = subset(diff, log2FC == -4), width = 0.2, height = 0.2, color = "green")+
# 5.23修改 重设刻度间隔
scale_x_continuous(breaks=seq(-4,4,1))+
theme_classic()+
Expand All @@ -133,16 +134,16 @@ p =ggplot(diff[diff$log2FC < 4 & diff$log2FC > -4, ], aes(x=log2FC, y=log2CPM, c
annotate("text",x=3,y=15,label=table(diff$level)[2]) +
main_theme
# 5.23修改 加图例
legend= ggplot(diff, aes(x=log2FC, y=log2CPM, color=level)) +
geom_point() + theme_classic()+
scale_colour_manual(values=c("green","red","grey")) +
main_theme

p1=plot_grid(p,
plot_grid(get_legend(legend),
ncol = 1,
align = "hv"),
ncol = 2,align = "hv",rel_widths=c(9,1))
# legend= ggplot(diff, aes(x=log2FC, y=log2CPM, color=level)) +
# geom_point() + theme_classic()+
# scale_colour_manual(values=c("green","red","grey")) +
# main_theme
#
# p1=plot_grid(p,
# plot_grid(get_legend(legend),
# ncol = 1,
# align = "hv"),
# ncol = 2,align = "hv",rel_widths=c(9,1))
p
ggsave(opts$output, p1, width = opts$width, height = opts$height, units = "mm")
ggsave(opts$output, p, width = opts$width, height = opts$height, units = "mm")

138 changes: 138 additions & 0 deletions script/memusg
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#!/usr/bin/env python

# https://github.com/drewkett/memusg

import sys
import os
import signal
from time import sleep, time
from subprocess import *
from argparse import ArgumentParser, REMAINDER
import math

parser = ArgumentParser()
parser.add_argument('-o',
'--output-to-file',
help="Output usage to file",
default="")
parser.add_argument('-t',
'--time',
help="Output run time of subprocess as well",
default=False,
action='store_true')
parser.add_argument(
'-p',
'--poll-interval',
help="Polling interval in seconds to check for current memory usage",
type=float,
default=0.1)
parser.add_argument(
'-w',
'--write-interval',
help="Interval in seconds to write current peak usage to stdout while process is running (Disable using 0)",
type=float,
default=0)
parser.add_argument(
'-H',
'--no-humanize',
help="No humanization of the value of time (second) and memory (KB) usage",
default=False,
action='store_true')
parser.add_argument('-s',
'--shell',
help="execute through shell, useful for multiple cmmands and commands with pipes",
default=False,
action='store_true')
parser.add_argument('args', nargs=REMAINDER)
args = parser.parse_args()


def get_rssize(sid):
"""Get total resident set memory of processes in session id"""
proc = Popen(['ps', '-o', 'rssize=', '--sid', str(sid)], stdout=PIPE)
stdout, _ = proc.communicate()
return sum(int(line.strip()) for line in stdout.split() if line.strip())


def human_time(t):
if t < 60:
return "{:.3f}s".format(t)
elif t < 60 * 60:
minutes = (t % 3600) // 60
seconds = (t % 60)
return "{:.0f}m:{:02.0f}s".format(minutes, seconds)
elif t < 24 * 60 * 60:
hours = (t % (24 * 60 * 60)) // 3600
minutes = (t % 3600) // 60
seconds = (t % 60)
return "{:.0f}h:{:02.0f}m:{:02.0f}s".format(hours, minutes, seconds)
else:
days = t // (24 * 60 * 60)
hours = (t % (24 * 60 * 60)) // 3600
minutes = (t % 3600) // 60
seconds = (t % 60)
return "{}days {:.0f}h:{:02.0f}m:{:02.0f}s".format(days, hours, minutes, seconds)


def human_size(size):
"""Convert integer representing bytes to human readable string"""
size_name = ("KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
if size:
i = int(math.floor(math.log(size, 1024)))
p = math.pow(1024, i)
s = round(size / p, 2)
return '%s %s' % (s, size_name[i])
else:
return '0B'


if args.output_to_file:
stdout = open(args.output_to_file, "w")
else:
stdout = sys.stderr

if args.time:
start_time = time()

if sys.version_info >= (3, 0):
p = Popen(tuple(args.args), start_new_session=True, shell=args.shell)
else:
p = Popen(tuple(args.args), preexec_fn=os.setsid, shell=args.shell)

# Catch interrupt signal and send to subprocesses
signal.signal(signal.SIGINT, lambda signum, frame: os.killpg(p.pid, signum))

if args.write_interval:
n_interval = int(args.write_interval / args.poll_interval)
last_peak = 0

peak = 0
n = 0
while p.poll() is None:
peak = max(peak, get_rssize(os.getsid(p.pid)))
n += 1
# Check every {write_interval} seconds if current peak memory usage is
# greater than previously output peak memory usage
if args.write_interval and (n % n_interval) == 0:
if peak > last_peak:
sys.stdout.write("peak rss: {}\n".format(
human_size(peak) if not args.no_humanize else peak))
last_peak = peak
sleep(args.poll_interval)

stdout.write("\n")
if args.time:
elapsed_time = time() - start_time
stdout.write("elapsed time: {}\n".format(human_time(
elapsed_time) if not args.no_humanize else "{:.3f}".format(elapsed_time)))
stdout.write("peak rss: {}\n".format(
human_size(peak) if not args.no_humanize else peak))
stdout.write("\n")

# Return subprocess return code except when returncode is negative, which
# indicates the subprocess was killed by a signal. Don't know how to get
# returncode in that case
if p.returncode < 0:
sys.exit(255)
else:
sys.exit(p.returncode)

0 comments on commit 6590d81

Please sign in to comment.